using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Drawing.Text;
using WP.DB;
using System.Runtime.InteropServices;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
using System.Drawing.Printing;
using WP.Commons.ToExcelProc;

namespace WP.Commons
{
    //this file include some small class which do not include any method of accessing database .


    public class LoginUtil
    {
        public LoginUtil()
        {
        }

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

        [DllImport("kernel32")]
        private static extern int WritePrivateProfileString(string section, string key, string Text, string filePath);

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileSection(string section, [MarshalAs(UnmanagedType.LPArray)] byte[] ReturnedString, int nSize, string FileName);

        [DllImport("Advapi32.dll", EntryPoint = "GetUserName", ExactSpelling = false, SetLastError = true)]
        static extern bool GetUserName([MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer, [MarshalAs(UnmanagedType.LPArray)] Int32[] nSize);


        public string GetWinUserName()
        {
            string strWinUserName;
            byte[] str = new byte[256];
            Int32[] len = new Int32[1];
            len[0] = 256;
            GetUserName(str, len);

            if (len[0] > 0)
            {
                strWinUserName = System.Text.Encoding.ASCII.GetString(str);
                strWinUserName = strWinUserName.Substring(0, len[0] - 1);
            }
            else
                strWinUserName = "";

            return strWinUserName;
        }

        public bool GetFile(string strFileName)
        {
            bool bGetFile = false;
            if (strFileName == null) strFileName = "";
            if (File.Exists(strFileName))
            {
                bGetFile = true;
            }
            else
            {
                int iDirIndex = strFileName.IndexOf("/", 0);
                if (iDirIndex != -1)
                {
                    string strDir = strFileName.Substring(0, iDirIndex);
                    if (!Directory.Exists(strDir))
                    {
                        Directory.CreateDirectory(strDir);
                    }
                }
            }
            return bGetFile;
        }

        public void CreateLogFile(string FileName)
        {
            StreamWriter writer = new StreamWriter(FileName, true);
            string strIni = "";
            strIni = "[LastLogin]" + "\r\n";
            strIni += "ServerTotal=0" + "\r\n";
            strIni += "DatabaseTotal=0" + "\r\n" + "\r\n";
            strIni += "[Server]" + "\r\n";
            strIni += "[Database]" + "\r\n";
            strIni += "[Show]" + "\r\n";
            strIni += "FirstShow=frmMain" + "\r\n";
            strIni += "MtnStartTabPage=0" + "\r\n" + "\r\n";
            strIni += "[Exit]" + "\r\n";
            strIni += "Ask=Y" + "\r\n";
            strIni += "ExitTo=Windows" + "\r\n" + "\r\n";
            strIni = strIni + "[View]" + "\r\n";
            strIni = strIni + "Switch=Y" + "\r\n";
            strIni = strIni + "Toolbar=Y" + "\r\n" + "\r\n";
            strIni = strIni + "[LastMenu]" + "\r\n";
            strIni = strIni + "MenuID=";
            writer.WriteLine(strIni);
            writer.Close();

        }

        public string GetInIString(string Section, string Key, string FileName)
        {
            int i;
            StringBuilder sbReturn = new StringBuilder(255);
            string GetInIString = "";

            if (FileName == "") return "";
            if (!GetFile(FileName))
            {
                GetInIString = "";
            }
            else
            {
                i = GetPrivateProfileString(Section, Key, "", sbReturn, 255, FileName);
                if (i > 0)
                {
                    string strReturn = sbReturn.ToString();
                    strReturn = strReturn.Substring(0, i);
                    GetInIString = strReturn.Trim();
                }
                else
                    GetInIString = "";
            }
            return GetInIString;

        }

        public int WriteIniString(string Section, string Key, string strText, string FileName)
        {
            int i;
            int intWriteIniString = 0;

            if (FileName != "")
            {
                if (!GetFile(FileName))
                    intWriteIniString = 0;
                else
                {
                    i = WritePrivateProfileString(Section, Key, strText, FileName);
                    intWriteIniString = i;
                }

            }
            return intWriteIniString;
        }

        public string GetInISection(string Section, string FileName)
        {
            int i;
            string strGetInISection = "";
            byte[] str = new byte[1000];
            if (FileName != "")
            {
                if (!GetFile(FileName))
                    strGetInISection = "";
                else
                {
                    i = GetPrivateProfileSection(Section, str, 1000, FileName);
                    if (i > 0)
                    {
                        strGetInISection = System.Text.Encoding.ASCII.GetString(str);
                        strGetInISection = strGetInISection.Substring(0, i);
                    }
                    else
                        strGetInISection = "";
                }
            }

            return strGetInISection;
        }
        public string GetResourcedir(bool bFirstLoadSystem)
        {
            string strCurrentDir;
            string strResourcePath;
            string strResourceFile;
            strCurrentDir = System.Windows.Forms.Application.ExecutablePath.ToString();
            strCurrentDir = strCurrentDir.Substring(0, strCurrentDir.Length - 24);
            strResourcePath = strCurrentDir + "Resource/";
            strResourceFile = strResourcePath + Constants.LOGFILE_NAME;
            if (bFirstLoadSystem)
            {
                if (!Directory.Exists(strResourceFile))
                {
                    //					strResourcePath = App.Path + "/resource/";
                }
            }
            return strResourcePath;
        }

    }

    public class mySortControlByIndex : System.Collections.IComparer
    {
        int System.Collections.IComparer.Compare(Object x, Object y)
        {
            Control xcon = x as Control;
            Control ycon = y as Control;
            return xcon.TabIndex - ycon.TabIndex;
        }
    }
    public class mySortControlByName : System.Collections.IComparer
    {
        int System.Collections.IComparer.Compare(Object x, Object y)
        {
            Control xcon = x as Control;
            Control ycon = y as Control;
            return string.Compare(xcon.Name, ycon.Name);
        }
    }
    public class myFindControlByName : System.Collections.IComparer
    {

        int System.Collections.IComparer.Compare(Object x, Object y)
        {
            Control con = x as Control;
            if (con != null)
            {
                return string.Compare(con.Name, y.ToString(), true);
            }
            else
            {
                con = y as Control;
                return string.Compare(con.Name, x.ToString(), true);
            }
        }
    }


    #region ModuleInfo class
    public class ModuleInfo
    {
        public ModuleInfo()
        {

        }
        public ModuleInfo(SystemModules sysModule)
        {
            WhatModule = sysModule;
        }
        private static string m_strCurrentModuleName = "";
        private static string m_strCurrentModuleID = "";
        private static string m_strCurrentSecurityGrp = "";
        private static SystemModules m_SystemModules = SystemModules.AP;

        public static string ModuleName
        {
            get
            {
                return m_strCurrentModuleName;
            }
            set
            {
                m_strCurrentModuleName = value;
            }
        }

        public static string ModuleID
        {
            get
            {
                return m_strCurrentModuleID;
            }
            set
            {
                m_strCurrentModuleID = value;
            }
        }

        public static SystemModules WhatModule
        {
            get
            {
                return m_SystemModules;
            }
            set
            {

                m_SystemModules = value;
                switch (value)
                {
                    case SystemModules.AP:
                        m_strCurrentModuleID = Prefix.AP;
                        m_strCurrentModuleName = "AP";
                        m_strCurrentSecurityGrp = "apSecurGrp";
                        break;
                    case SystemModules.AR:
                        m_strCurrentModuleName = "AR";
                        m_strCurrentModuleID = Prefix.AR;
                        m_strCurrentSecurityGrp = "arSecurGrp";
                        break;
                    case SystemModules.ES:
                        m_strCurrentModuleName = "ES";
                        m_strCurrentModuleID = Prefix.ES;
                        m_strCurrentSecurityGrp = "mfSecurGrp";
                        break;
                    case SystemModules.GL:
                        m_strCurrentModuleName = "GL";
                        m_strCurrentModuleID = Prefix.GL;
                        m_strCurrentSecurityGrp = "glSecurGrp";
                        break;
                    case SystemModules.IM:
                        m_strCurrentModuleName = "IM";
                        m_strCurrentModuleID = Prefix.IM;
                        m_strCurrentSecurityGrp = "imSecurGrp";
                        break;
                    case SystemModules.MF:
                        m_strCurrentModuleName = "MF";
                        m_strCurrentModuleID = Prefix.MF;
                        m_strCurrentSecurityGrp = "mfSecurGrp";
                        break;
                    case SystemModules.OE:
                        m_strCurrentModuleName = "OE";
                        m_strCurrentModuleID = Prefix.OE;
                        m_strCurrentSecurityGrp = "oeSecurGrp";
                        break;
                    case SystemModules.PO:
                        m_strCurrentModuleName = "PO";
                        m_strCurrentModuleID = Prefix.PO;
                        m_strCurrentSecurityGrp = "poSecurGrp";
                        break;
                    case SystemModules.RM:
                        m_strCurrentModuleName = "RM";
                        m_strCurrentModuleID = Prefix.RM;
                        m_strCurrentSecurityGrp = "rmSecurGrp";
                        break;
                    case SystemModules.TP:
                        m_strCurrentModuleName = "TP";
                        m_strCurrentModuleID = Prefix.TP;
                        m_strCurrentSecurityGrp = "tpSecurGrp";
                        break;
                    case SystemModules.PD:
                        m_strCurrentModuleName = "PD";
                        m_strCurrentModuleID = Prefix.PD;
                        m_strCurrentSecurityGrp = "pdSecurGrp";
                        break;
                    case SystemModules.TW:
                        m_strCurrentModuleName = "TW";
                        m_strCurrentModuleID = Prefix.TW;
                        m_strCurrentSecurityGrp = "twSecurGrp";
                        break;
                    case SystemModules.CR:
                        m_strCurrentModuleName = "CR";
                        m_strCurrentModuleID = Prefix.CR;
                        m_strCurrentSecurityGrp = "crmSecurGrp";
                        break;
                }
            }
        }

        public static string ModuleSecurityGrp
        {
            get
            {
                return m_strCurrentSecurityGrp;
            }
        }

        public static string SecurityGrp(string MenuId)
        {
            string strPrefix = MenuId.Trim().Substring(0, 3);
            if (strPrefix == Prefix.GL)
                return "glSecurGrp";
            else if (strPrefix == Prefix.AP)
                return "apSecurGrp";
            else if (strPrefix == Prefix.AR)
                return "arSecurGrp";
            else if (strPrefix == Prefix.OE)
                return "oeSecurGrp";
            else if (strPrefix == Prefix.IM)
                return "imSecurGrp";
            else if (strPrefix == Prefix.PO)
                return "poSecurGrp";
            else if (strPrefix == Prefix.RM)
                return "rmSecurGrp";
            else if (strPrefix == Prefix.TW)
                return "twSecurGrp";
            else if (strPrefix == Prefix.TP)
                return "tpSecurGrp";
            else if (strPrefix == Prefix.ES)
                return "mfSecurGrp";
            else if (strPrefix == Prefix.MF)
                return "mfSecurGrp";
            else if (strPrefix == Prefix.PD)
                return "pdSecurGrp";
            else if (strPrefix == Prefix.CR)
                return "crmSecurGrp";
            else
                return "";

        }
        public class Prefix
        {
            public const string GL = "010";
            public const string AP = "020";
            public const string AR = "030";
            public const string OE = "040";
            public const string IM = "050";
            public const string PO = "060";
            public const string RM = "090";
            public const string TW = "100";
            public const string PD = "120";
            public const string TP = "200";
            public const string ES = "600";
            public const string MF = "900";
            public const string CR = "036";
        }
        public class StrModule
        {
            public const string GL = "010%";
            public const string AP = "020%";
            public const string AR = "030%";
            public const string OE = "040%";
            public const string IM = "050%";
            public const string PO = "060%";
            public const string RM = "090%";
            public const string TW = "100%";
            public const string PD = "120%";
            public const string TP = "200%";
            public const string ES = "600%";
            public const string MF = "900%";
            public const string CR = "036%";
        }
    }
    #endregion

    #region JournalFileInfo class
    public class JournalFileInfo
    {

        public class JournalType
        {
            public string JournalFileName;
            public JournalType(string strJournalFileName)
            {
                JournalFileName = strJournalFileName;
            }
        }



        public static JournalType ARPost
        {
            get
            {
                return new JournalType("ARCashRcvList");
            }
        }

        public static JournalType ARAdjustPost
        {
            get
            {
                return new JournalType("ARAdjustment");
            }
        }

        public static JournalType APPost
        {
            get
            {
                return new JournalType("APMChq");
            }
        }

        public static JournalType POPost
        {
            get
            {
                return new JournalType("POGoodRecv");
            }
        }

        public static JournalType OEPost
        {
            get
            {
                return new JournalType("OEOrderEntry");
            }
        }

        public static JournalType OEPostSalesRebateAdjust
        {
            get
            {
                return new JournalType("OERebateAdjust");
            }
        }


        public static JournalType IMPost
        {
            get
            {
                return new JournalType("");
            }
        }

        public static JournalType RMPost
        {
            get
            {
                return new JournalType("RMFinWO");
            }
        }

        public static JournalType APCPost
        {
            get
            {
                return new JournalType("APCChq");
            }
        }

        public static JournalType APSupInvPost
        {
            get
            {
                return new JournalType("APSupInv");
            }
        }

        public static JournalType APAccru
        {
            get
            {
                return new JournalType("APAccru");
            }
        }

        public static JournalType APFreightAccru
        {
            get
            {
                return new JournalType("APFreightAccru");
            }
        }
        public static JournalType APPrepaidFreightAccru
        {
            get
            {
                return new JournalType("APPrepaidFreightAccru");
            }
        }


        public static JournalType JnlEntryPost
        {
            get
            {
                return new JournalType("GLJnlEntry");
            }
        }

        public static JournalType GLInterfacePost
        {
            get
            {
                return new JournalType("GLInterface");
            }
        }

        public static JournalType IMSTKPost
        {
            get
            {
                return new JournalType("ImSTK");
            }
        }

        public static JournalType IMAdjCost
        {
            get
            {
                return new JournalType("ImAdjCost");
            }
        }

        public static JournalType IMAdjQty
        {
            get
            {
                return new JournalType("ImAdjQty");
            }
        }

        public static JournalType OeAdjCommissionCost
        {
            get
            {
                return new JournalType("OeAdjCommissionCost");
            }
        }



        public static JournalType IMTrfPost
        {
            get
            {
                return new JournalType("ImTrf");
            }
        }
        public static JournalType IMInterCompTrfPost
        {
            get
            {
                return new JournalType("ImInterCompTrf");
            }
        }
        public static JournalType GLAllocate
        {
            get
            {
                return new JournalType("GLAllocate");
            }
        }

        public static JournalType ARTrdInvChrgPost
        {
            get
            {
                return new JournalType("ArTrdInvChrg");
            }
        }

        public static JournalType ARTrdInterstChrgPost
        {
            get
            {
                return new JournalType("ARTrdInterstChrgPost");
            }
        }

        public static JournalType IMAdjTag
        {
            get
            {
                return new JournalType("ImAdjTag");
            }
        }

        public static JournalType OEReturn
        {
            get
            {
                return new JournalType("OeReturn");
            }
        }

        public static JournalType ARCustInterestChrgPost
        {
            get
            {
                return new JournalType("ArCustInterestChrgPost");
            }
        }

        public static JournalType IMInvOpenBalPost
        {
            get
            {
                return new JournalType("ImInvOpenBal");
            }
        }

        public static JournalType IMTreatmentPost
        {
            get
            {
                return new JournalType("ImTreatmentPost");
            }
        }

        public static JournalType APVoidCPost
        {
            get
            {
                return new JournalType("APVoidCChq");
            }
        }

        public static JournalType IMInvAdjByGroupPost
        {
            get
            {
                return new JournalType("ImInvAdjustmentByGroupPost");
            }
        }

        public static JournalType APOpenBalPost
        {
            get
            {
                return new JournalType("ApOpenBalPost");
            }
        }
        public static JournalType APAccruOpenBalPost
        {
            get
            {
                return new JournalType("ApAccruOpenBalPost");
            }
        }

        public static JournalType AROpenBalPost
        {
            get
            {
                return new JournalType("ArOpenBalPost");
            }
        }

        public static JournalType GLOpenBalPost
        {
            get
            {
                return new JournalType("GlOpenBalPost");
            }
        }

        public static JournalType IMChargeEntryPost
        {
            get
            {
                return new JournalType("ImChargeEntryPost");
            }
        }

        public static JournalType IMTagTransferPost
        {
            get
            {
                return new JournalType("ImTagTrfPost");
            }
        }

        public static JournalType IMTreatProcessPost
        {
            get
            {
                return new JournalType("ImTreatProcessPost");
            }
        }

        public static JournalType OECashBalPost
        {
            get
            {
                return new JournalType("OECashBal");
            }
        }

        public static JournalType IMTreatToColonie
        {
            get
            {
                return new JournalType("ImTreatToColoniePost");
            }
        }

        public static JournalType OETSOGoodsRecvPost
        {
            get
            {
                return new JournalType("OETSOGoodsRecvPost");
            }
        }

        public static JournalType IMInvProdPost
        {
            get
            {
                return new JournalType("ImInvProdPost");
            }
        }

        public static JournalType IMChargeDryPost
        {
            get
            {
                return new JournalType("ImChargeDryPost");
            }
        }

        public static JournalType IMInterCmpTrfPost
        {
            get
            {
                return new JournalType("ImInterCmpTrfPost");
            }
        }

        public static JournalType POReturnPost
        {
            get
            {
                return new JournalType("PORtnGoodRecv");
            }
        }

        public static JournalType APAccruOpenBal
        {
            get
            {
                return new JournalType("APAccruOpenBal");
            }
        }

        public static JournalType APVoidMPost
        {
            get
            {
                return new JournalType("APVoidMPost");
            }
        }

        public static JournalType OEVoidReturn
        {
            get
            {
                return new JournalType("OeVoidReturn");
            }
        }

        public static JournalType IMReAvgCost
        {
            get
            {
                return new JournalType("ImReAvgCost");
            }
        }

        public static JournalType IMAdjQtyCost
        {
            get
            {
                return new JournalType("ImAdjQtyCost");
            }
        }

        public static JournalType ARTrdPaymentInterstChrgPost
        {
            get
            {
                return new JournalType("ARTrdPaymentInterstChrgPost");
            }
        }

        public static JournalType IMInvOpenBalByTagPost
        {
            get
            {
                return new JournalType("ImInvOpenBalByTag");
            }
        }

        public static JournalType RMRunPost
        {
            get
            {
                return new JournalType("RMRun");
            }
        }

        public static JournalType POSupVMIGoodsRecvPost
        {
            get
            {
                return new JournalType("POSupVMIGoodsRecv");
            }
        }

        public static JournalType POCustMillingGoodsRecvPost
        {
            get
            {
                return new JournalType("POCustMillingGoodsRecv");
            }
        }

        public static JournalType ARTrdPrePaidInvChrgPost
        {
            get
            {
                return new JournalType("ArTrdPrePaidInvChrg");
            }
        }

        public static JournalType APAccruClearing
        {
            get
            {
                return new JournalType("APAccruClearing");
            }
        }

        public static JournalType IMInvProdIssuesPost
        {
            get
            {
                return new JournalType("ImInvProdIssuesPost");
            }
        }

        public static JournalType RMBackFlashingPost
        {
            get
            {
                return new JournalType("RMBackFlushing");
            }
        }

        public static JournalType RMBOMBackFlashingPost
        {
            get
            {
                return new JournalType("RMBOMBackFlushing");
            }
        }

        public static JournalType APAdjustPost
        {
            get
            {
                return new JournalType("APAdjustPost");
            }
        }

        public static JournalType OECutEngineeredWoodPost
        {
            get
            {
                return new JournalType("OECutEngineeredWood");
            }
        }

        public static JournalType IMInvProdRetPost
        {
            get
            {
                return new JournalType("ImInvProdRetPost");
            }
        }

        public static JournalType OETrfPost
        {
            get
            {
                return new JournalType("OeTRF");
            }
        }
        public static JournalType GlInterCompFundTrfPost
        {
            get
            {
                return new JournalType("GlInterCompFundTrfPost");
            }
        }
        public static JournalType ARVoidPost
        {
            get
            {
                return new JournalType("ARVoidCashRcvList");
            }
        }

        public static JournalType APACHPost
        {
            get
            {
                return new JournalType("APACHPost");
            }
        }
    }
    #endregion
    #region SystemDateOption class
    public class SystemDateOption
    {
        public static string optDateFmtMDY
        {
            get { return "MM/dd/yyyy"; }
        }
        public static string optFmtDtp
        {
            get { return "MM/dd/yyy"; }
        }
        public static string optDateFmtYMD
        {
            get { return "yyyy/MM/dd"; }
        }
        public static string optDateFmtMY
        {
            get { return "MM/yyyy"; }
        }
        public static string GetFormat(DateFormatOption opt)
        {
            switch (opt)
            {
                case DateFormatOption.DateFmtMDY:
                    return SystemDateOption.optDateFmtMDY;
                case DateFormatOption.FmtDtp:
                    return SystemDateOption.optFmtDtp;
                case DateFormatOption.DateFmtYMD:
                    return SystemDateOption.optDateFmtYMD;
                case DateFormatOption.DateFmtMY:
                    return SystemDateOption.optDateFmtMY;

            }
            return "";

        }
    }
    #endregion

    #region data brow class
    public partial class frmDataBrow
    {

        private void btnOk_Click(object sender, EventArgs e)
        {
            Control con = sender as Control;
            if (con != null) (con.Parent.Parent as Form).Close();
        }

        public void Brow(DataView dv, string strFormCaption)
        {
            Form f = new Form();
            f.Size = new Size(800, 500);
            f.Text = (strFormCaption.Trim() == "" ? "Data Brow" : strFormCaption);
            f.FormBorderStyle = FormBorderStyle.SizableToolWindow;
            f.StartPosition = FormStartPosition.CenterScreen;
            System.Windows.Forms.DataGridView dgView = new DataGridView();
            System.Windows.Forms.Button btnOk = new Button(); ;
            btnOk.Size = new Size(75, 20);
            dgView.Parent = f;
            btnOk.Text = "&Ok";
            dgView.Size = new Size(f.ClientSize.Width, f.ClientSize.Height - btnOk.Height);

            dgView.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            dgView.DataSource = dv;

            dgView.AllowUserToAddRows = false;

            btnOk.Click += new EventHandler(btnOk_Click);
            TableLayoutPanel tlayout = new TableLayoutPanel();
            tlayout.Parent = f;
            tlayout.Location = new Point(0, f.ClientSize.Height - btnOk.Height - 3);
            tlayout.ColumnCount = 3;
            tlayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            tlayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F));
            tlayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            tlayout.Controls.Add(btnOk, 1, 0);
            tlayout.Size = new Size(f.ClientSize.Width, btnOk.Height + 5);
            tlayout.Anchor = AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left;
            tlayout.RowCount = 1;
            foreach (DataGridViewColumn ocol in dgView.Columns)
            {
                ocol.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
            }
            // dgView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.Fill );
            f.TopMost = true;
            f.ShowDialog();

        }

    }
    #endregion

    #region About report Print
    public class PrintInfo
    {
        public enum OutputType { Preview = 0, Print, PDF, Excel, Email, Fax, Nothing };

        public enum ExportType { PDF = 3, Excel };
        /*
         * this is for save report. the name will be used file name. 
         */

        private System.Collections.Specialized.NameValueCollection mVarCollection = new System.Collections.Specialized.NameValueCollection();
        public System.Collections.Specialized.NameValueCollection VarCollection
        {
            get { return mVarCollection; }
            set { mVarCollection = value; }
        }
        private string m_FaxEmailInfo = "";

        public string FaxEmailInfo
        {
            get
            {
                return m_FaxEmailInfo;
            }
            set
            {
                m_FaxEmailInfo = value;
            }
        }


        private string m_ReportExportFileName = "";
        public string ReportExportFileName
        {
            get
            {
                return this.m_ReportExportFileName;
            }
            set
            {
                this.m_ReportExportFileName = value;
            }
        }
        private ExportType m_ReporExportType = ExportType.PDF;
        public ExportType ReportExportType
        {
            get
            {
                return this.m_ReporExportType;
            }
            set
            {
                this.m_ReporExportType = value;
            }
        }

        private string m_ReportTitle = "";
        public string ReportTitle
        {
            get
            {
                return this.m_ReportTitle;
            }
            set
            {
                this.m_ReportTitle = value;
            }
        }
        private string m_ReportPageTitle = "";
        public string ReportPageTitle
        {
            get
            {
                return this.m_ReportPageTitle;
            }
            set
            {
                this.m_ReportPageTitle = value;
            }
        }
        private string m_PrinterName = string.Empty;

        private string m_PrintCondition = "";

        public string PrintCondition
        {
            get
            {
                return this.m_PrintCondition;
            }
            set
            {
                this.m_PrintCondition = value;
            }
        }
        public string PrinterName
        {
            get
            {
                if (m_PrinterName.Length > 0)
                {
                    return m_PrinterName;
                }
                else
                {
                    return this.m_PrinterSetting.PrinterName;
                }
            }
            set
            {
                this.m_PrinterName = value;
            }
        }

        private PrinterSettings m_PrinterSetting;
        public PrinterSettings PrinterSetting
        {
            get
            {
                if (m_PrinterSetting == null)
                {
                    m_PrinterSetting = new PrinterSettings();
                }
                return this.m_PrinterSetting;
            }
            set
            {
                this.m_PrinterSetting = value;
            }
        }

        private OutputType m_OutputType = OutputType.Preview;
        public OutputType PrintType
        {
            get
            {
                return m_OutputType;
            }
            set
            {
                m_OutputType = value;
            }

        }

        private bool m_Landscape = false;

        public bool Landscape
        {
            get
            {
                return this.m_Landscape;
            }
            set
            {
                this.m_Landscape = value;
            }
        }

        /*
         * The pixel depth of the color range supported by the image output. 
         * Valid values are 1, 4, 8, 24, and 32. 
         * The default value is 24. 
         * ColorDepth is only supported for TIFF rendering and is otherwise ignored by the report server for other image output formats. 
         * Note: 
         * For this release of SQL Server, the value of this setting is ignored, and the TIFF image is always rendered as 24-bit.
        */
        private int m_ColorDepth = 24;

        public int ColorDepth
        {
            get
            {
                return this.m_ColorDepth;
            }
        }


        /*
         * The number of columns to set for the report. This value overrides the report's original settings.
         * 
         * not used
         * 
        */
        private int m_Columns = 0;

        public int Columns
        {
            get
            {
                return this.m_Columns;
            }
            set
            {
                this.m_Columns = value;
            }
        }


        /*
         * The column spacing to set for the report. This value overrides the report's original settings.
         * 
         * not used
         * 
        */
        private int m_ColumnSpacing = 0;

        public int ColumnSpacing
        {
            get
            {
                return this.m_ColumnSpacing;
            }
            set
            {
                this.m_ColumnSpacing = value;
            }
        }

        /*
         * The resolution of the output device in x-direction. The default value is 96.
         * 
        */
        private int m_DpiX = 96;

        public int DpiX
        {
            get
            {
                return this.m_DpiX;
            }
            set
            {
                this.m_DpiX = value;
            }
        }


        /*
         * The resolution of the output device in y-direction. The default value is 96.
         * 
        */
        private int m_DpiY = 96;

        public int DpiY
        {
            get
            {
                return this.m_DpiY;
            }
            set
            {
                this.m_DpiY = value;
            }
        }


        /*
         * The last page of the report to render. The default value is the value for StartPage.
         * 
         */
        private int m_EndPage = 0;

        public int EndPage
        {
            get
            {
                return this.m_EndPage;
            }
            set
            {
                this.m_EndPage = value;
            }
        }


        /*
         * The first page of the report to render. A value of 0 indicates that all pages are rendered. The default value is 1.
         * 
         */
        private int m_StartPage = 1;

        public int StartPage
        {
            get
            {
                return this.m_StartPage;
            }
            set
            {
                this.m_StartPage = value;
            }
        }

        /*
         * The bottom margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings.
         * 
         */
        private decimal m_MarginBottom = 0;

        public decimal MarginBottom
        {
            get
            {
                return this.m_MarginBottom;
            }
            set
            {
                this.m_MarginBottom = value;
            }
        }


        /*
         * The top margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings.
         * 
         */
        private decimal m_MarginTop = 0;

        public decimal MarginTop
        {
            get
            {
                return this.m_MarginTop;
            }
            set
            {
                this.m_MarginTop = value;
            }
        }


        /*
         * The left margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings.
         * 
         */
        private decimal m_MarginLeft = 0;

        public decimal MarginLeft
        {
            get
            {
                return this.m_MarginLeft;
            }
            set
            {
                this.m_MarginLeft = value;
            }
        }


        /*
         * The right margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings.
         *  
         */
        private decimal m_MarginRight = 0;

        public decimal MarginRight
        {
            get
            {
                return this.m_MarginRight;
            }
            set
            {
                this.m_MarginRight = value;
            }
        }

        /*
         * One of the Graphics Device Interface (GDI) supported output formats: BMP, EMF, GIF, JPEG, PNG, or TIFF.
         * 
         */
        private string m_OutputFormat = "EMF";

        public string OutputFormat
        {
            get
            {
                return this.m_OutputFormat;
            }
            set
            {
                this.m_OutputFormat = value;
            }
        }

        /*
         * The page height, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 11in). This value overrides the report's original settings.
         * 
         */
        private decimal m_PageHeight = 11;

        public decimal PageHeight
        {
            get
            {
                return this.m_PageHeight;
            }
            set
            {
                this.m_PageHeight = value;
            }
        }


        /*
         * The page width, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 8.5in). This value overrides the report's original settings.
         * 
         * 
        */
        private decimal m_PageWidth = 8.5m;

        public decimal PageWidth
        {
            get
            {
                return this.m_PageWidth;
            }
            set
            {
                this.m_PageWidth = value;
            }
        }

        public string DeviceInfoString
        {
            get
            {
                string strRet = string.Empty;

                strRet += "<DeviceInfo>" +
                    "  <OutputFormat>" + this.m_OutputFormat + "</OutputFormat>";

                if (this.m_Landscape)
                    strRet +=
                        "  <PageWidth>" + this.m_PageHeight.ToString() + "in</PageWidth>" +
                        "  <PageHeight>" + this.m_PageWidth.ToString() + "in</PageHeight>";
                else
                    strRet +=
                        "  <PageWidth>" + this.m_PageWidth.ToString() + "in</PageWidth>" +
                        "  <PageHeight>" + this.m_PageHeight.ToString() + "in</PageHeight>";

                strRet +=
                        "  <MarginTop>" + this.m_MarginTop.ToString() + "in</MarginTop>" +
                        "  <MarginLeft>" + this.m_MarginLeft.ToString() + "in</MarginLeft>" +
                        "  <MarginRight>" + this.m_MarginRight.ToString() + "in</MarginRight>" +
                        "  <MarginBottom>" + this.m_MarginBottom.ToString() + "in</MarginBottom>";

                strRet += "</DeviceInfo>";

                return strRet;

            }
        }
    }
    #endregion

    #region OE system customize report type
    public class OeCustomizeReportType
    {

        private OeCustomizeReportTypeOption mOeCustomizeReportTypeOption = OeCustomizeReportTypeOption.OfficeCopy;
        public OeCustomizeReportType(OeCustomizeReportTypeOption opt)
        {
            mOeCustomizeReportTypeOption = opt;
        }

        public OeCustomizeReportTypeOption Type
        {
            set
            {
                mOeCustomizeReportTypeOption = value;
            }
        }
        public string GetTypeDesc()
        {
            return GetTypeDesc(false);
        }
        public string GetTypeDesc(bool blnAddCopy)
        {
            string strDesc = string.Empty;
            switch (mOeCustomizeReportTypeOption)
            {
                case OeCustomizeReportTypeOption.NoCopy:
                    strDesc = "";
                    blnAddCopy = false;
                    break;
                case OeCustomizeReportTypeOption.OfficeCopy:
                    strDesc = "OFFICE COPY";
                    blnAddCopy = false;
                    break;
                case OeCustomizeReportTypeOption.Office:
                    strDesc = "OFFICE";
                    break;
                case OeCustomizeReportTypeOption.Original:
                    strDesc = "Original".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.Customer:
                    strDesc = "Customer".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.Salesperson:
                    strDesc = "Salesperson".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.QuickEstimate:
                    strDesc = "Quick Estimate".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.SummaryEstimate:
                    strDesc = "Summary Estimate".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.DetailEstimate:
                    strDesc = "Detail Estimate with cost".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.BankEstimate:
                    strDesc = "Bank Estimate".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.WithCost:
                    strDesc = "Cost".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.FILE:
                    strDesc = "FILE".ToUpper();
                    break;
                case OeCustomizeReportTypeOption.ACCOUNTING:
                    strDesc = "ACCOUNTING".ToUpper();
                    break;

            }
            if (blnAddCopy)
            {
                strDesc += " COPY";
            }
            return strDesc;
        }


    }
    #endregion

    #region Convert Class
    public class CvtFunc
    {
        public static string ToString(object obj)
        {
            return ToString(obj, true);
        }
        private static string ToString(object obj, bool blnTrimEnd)
        {
            if (obj == null) return "";

            string strTo = obj.ToString();
            if (blnTrimEnd)
                strTo = strTo.TrimEnd();

            return strTo;
        }

        public static string ToLeftString(object obj, int iLength)
        {
            return ToLeftString(obj, iLength, true);
        }
        private static string ToLeftString(object obj, int iLength, bool blnTrimEnd)
        {
            if (obj == null) return "";
            if (iLength <= 0) return string.Empty;
            string strTo = ToString(obj, blnTrimEnd);
            if (strTo.Length > iLength)
                strTo = strTo.Substring(0, iLength);

            if (blnTrimEnd)
                strTo = strTo.TrimEnd();

            return strTo;

        }
        public static string ToRightString(object obj, int iLength)
        {
            return ToRightString(obj, iLength, true);
        }
        private static string ToRightString(object obj, int iLength, bool blnTrimEnd)
        {
            if (obj == null) return "";
            if (iLength <= 0) return string.Empty;
            string strTo = ToString(obj, blnTrimEnd);
            if (strTo.Length > iLength)
                strTo = strTo.Substring(strTo.Length - iLength);

            if (blnTrimEnd)
                strTo = strTo.TrimEnd();

            return strTo;
        }
        public static string ToSubstring(object obj, int iStartIndex)
        {
            string str = CvtFunc.ToString(obj);
            return ToSubstring(str, iStartIndex, str.Length, true);
        }
        public static string ToSubstring(object obj, int iStartIndex, int iLength)
        {
            return ToSubstring(obj, iStartIndex, iLength, true);
        }
        private static string ToSubstring(object obj, int iStartIndex, int iLength, bool blnTrimEnd)
        {
            if (obj == null) return "";
            if (iStartIndex < 0) return string.Empty;
            if (iLength <= 0) return string.Empty;
            string strTo = ToString(obj, blnTrimEnd);
            if (iStartIndex > strTo.Length || iStartIndex < 0 || iLength < 0)
            {
                return "";
            }
            else if (iStartIndex + iLength > strTo.Length)
            {
                strTo = strTo.Substring(iStartIndex);
            }
            else
                strTo = strTo.Substring(iStartIndex, iLength);

            if (blnTrimEnd)
                strTo = strTo.TrimEnd();

            return strTo;
        }


        public static string ToDateString(object obj)
        {
            if (obj == null || obj.ToString().TrimEnd() == "") return "";

            return BaseFunctions.FormatDate(obj.ToString());
        }

        public static DateTime ToDateTime(object obj)
        {
            if (obj == null || obj.ToString().TrimEnd() == "" || obj.ToString().Trim() == "/  /") return new DateTime(1900, 1, 1);

            return DateTime.Parse(obj.ToString());
        }

        public static double ToDouble(object obj)
        {
            return ToDouble(obj, -1);
        }
        public static double ToDouble(object obj, int intDecimalPoint)
        {
            string strFormatStyle = "";

            if (obj == null || obj.ToString().TrimEnd() == "") return 0;

            if (intDecimalPoint >= 0)
            {
                strFormatStyle = "N." + intDecimalPoint.ToString();
                return double.Parse(BaseFunctions.FormatNumeric(obj.ToString(), strFormatStyle));
            }
            else
            {
                //return double.Parse(obj.ToString());

                return double.Parse(BaseFunctions.FormatNumeric(obj, "n.n"));

            }
        }

        public static int ToInt(object obj)  //Int32
        {
            if (obj == null || obj.ToString().TrimEnd() == "" || !BaseFunctions.IsNumeric(obj.ToString())) return 0;

            return int.Parse(BaseFunctions.FormatNumeric(obj, "n.0"));
        }

        public static long ToLong(object obj) //Int64
        {
            if (obj == null || obj.ToString().TrimEnd() == "") return 0;

            return long.Parse(obj.ToString());
        }

        public static bool ToBoolean(object obj)
        {
            if (obj == null || obj.ToString().TrimEnd() == "") return false;

            if (obj.ToString().ToUpper() == "YES") return true;
            if (obj.ToString().ToUpper() == "NO") return false;
            if (obj.ToString().ToUpper() == "1") return true;
            if (obj.ToString().ToUpper() == "0") return false;

            return Convert.ToBoolean(obj.ToString());
        }




    }
    #endregion Convert Class

    public class Msg
    {
        public static string Select(string OrgMsg, string GetMsg)
        {
            return (GetMsg.Trim() == "" ? OrgMsg : GetMsg);
        }
    }

    #region History type
    public class HistoryType
    {
        public static string PoGoodsRecv { get { return "P/O"; } }
        public static string PoReturn { get { return "P/O"; } }
        public static string OeSalesOrder { get { return "O/E"; } }
        public static string OeReturn { get { return "O/E"; } }
        public static string RmInput { get { return "RMI"; } }
        public static string RmOutput { get { return "RMO"; } }
        public static string RmBillMaterialInput { get { return "RMI"; } }
        public static string RmBillMaterialOutput { get { return "RMO"; } }
        public static string RmBackFlashInput { get { return "RMI"; } }
        public static string RmBackFlashOutput { get { return "RMO"; } }
        public static string ImTransferFromLoc { get { return "TFO"; } } //from loc: iminvloc/iminvtag/iminvlot.transferout
        public static string ImTransferToLoc { get { return "TFI"; } }//to loc: iminvloc/iminvtag/iminvlot.transferin
        public static string ApAccuralQtyAdjust { get { return "APJ"; } }
        public static string ImAdjustQtyMinus { get { return "ADM"; } } //Reduce qty : iminvloc/iminvtag/iminvlot.adjustout
        public static string ImAdjustQtyPlus { get { return "ADP"; } } //Add qty: iminvloc/iminvtag/iminvlot.adjustin
        public static string ImAdjustCost { get { return "ADJ"; } }
        public static string ImOpenBalance { get { return "INV"; } }
        public static string ImProductRecv { get { return "PRO"; } }
        public static string ImProdIssues { get { return "PRI"; } }
        public static string ImSTKTaking { get { return "STK"; } }
        public static string ImTagAdjust { get { return "ADT"; } }    // tag adjust , may be add qty ,also may be reduce qty
        public static string ImSplitLot { get { return "SPL"; } }
        public static string ImSplitTag { get { return "SPT"; } }
        public static string ImLotAdjust { get { return "ADL"; } }
    }
    #endregion

    #region Customize Report
    public class PrintFormType
    {
        public static string APComputerCheck { get { return "AP Computer Check"; } }
        public static string APDepositeTicket { get { return "AP Deposite Ticket"; } }
        public static string ARCustomerStatement { get { return "AR Customer Statement"; } }
        public static string OESalesOrder { get { return "OE Sales Order"; } }
        public static string OEInvoice { get { return "OE Invoice"; } }
        public static string OEPullCard { get { return "OE Pull Card"; } }
        public static string OEBOL { get { return "OE Bill of Lading"; } }
        public static string OEGrossMargin { get { return "OE Gross Margin"; } }
        public static string OEDispatchTicket { get { return "OE Dispatch Ticket"; } }
        public static string OEReturn { get { return "OE Return"; } }
        public static string OEReturnPullCard { get { return "OE Return Pull Card"; } }
        public static string OEReturnBOL { get { return "OE Return Bill of Lading"; } }
        public static string OEReturnGrossMargin { get { return "OE Return Gross Margin"; } }
        public static string OEQuotation { get { return "OE Quotation"; } }
        public static string IMTransfer { get { return "IM Transfer"; } }
        public static string IMTransferPullCard { get { return "IM Transfer Pull Card"; } }
        public static string IMTransferBOL { get { return "IM Transfer Bill of Lading"; } }
        public static string POPurchaseOrder { get { return "PO Purchase Order"; } }
        public static string RMWorkOrder { get { return "RM Work Order"; } }
    }
    public class CustomizeReportType
    {
        public static Type CurrentType()
        {
            return CurrentType(string.Empty);
        }
        public static Type CurrentType(string strProgName)
        {
            switch (strProgName)
            {
                case "Print1099Form":
                    if (Customize.IsNuPro()) return Type.GetType("WP.Customize.NuproDemo.Report," + "WP.Customize.NuproDemo", true, true);
                    return Type.GetType("WP.Customize.Demo.Report," + "WP.Customize.Demo", true, true);
                    break;
                case "OECutEngineeredWood":
                    //2008-12-17    Z   alwayse use demo
                    if (Customize.IsNuPro()) return Type.GetType("WP.Customize.NuproDemo.Report," + "WP.Customize.NuproDemo", true, true);
                    return Type.GetType("WP.Customize.Demo.Report," + "WP.Customize.Demo", true, true);
                    break;
                default:
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || SysVar.CodeSignNo == SysVar.DefineCompany.FoodPro)
                    {
                        if (Customize.IsNuPro()) return Type.GetType("WP.Customize.NuproDemo.Report," + "WP.Customize.NuproDemo", true, true);
                        return Type.GetType("WP.Customize.Demo.Report," + "WP.Customize.Demo", true, true);
                    }
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.JonesLumber) return Type.GetType("WP.Customize.JonesLumber.Report," + "WP.Customize.JonesLumber", true, true);


                    if (SysVar.CodeSignNo == SysVar.DefineCompany.Mayfair) return Type.GetType("WP.Customize.Mayfair.Report," + "WP.Customize.Mayfair", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.Nash) return Type.GetType("WP.Customize.Nash.Report," + "WP.Customize.Nash", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.MaritimeForestProducts) return Type.GetType("WP.Customize.MaritimeForestProducts.Report," + "WP.Customize.MaritimeForestProducts", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.ManionsSuperior || SysVar.CodeSignNo == SysVar.DefineCompany.ManionsStCloud) return Type.GetType("WP.Customize.Manions.Report," + "WP.Customize.Manions", true, true);

                    #region RockyTop
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.RockyTop
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopCACLYLE
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopFIVESTAR
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopRTWP
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTFG
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTFGLeasing
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTFGPropMD
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTFGPropOH
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTFGPropPA
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTFGPropRM
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTFGPropRMW
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTSOMD
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTSOOH
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTSOVA
                        || SysVar.CodeSignNo == SysVar.DefineCompany.RockyTopTSOVAREMAN)
                        return Type.GetType("WP.Customize.RockyTop.Report," + "WP.Customize.RockyTop", true, true);
                    #endregion

                    #region Empire
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.EmpireCO || SysVar.CodeSignNo == SysVar.DefineCompany.EmpireLTD) return Type.GetType("WP.Customize.Empire.Report," + "WP.Customize.Empire", true, true);
                    #endregion

                    if (SysVar.CodeSignNo == SysVar.DefineCompany.MooreHardwoods) return Type.GetType("WP.Customize.MooreHardwoods.Report," + "WP.Customize.MooreHardwoods", true, true);

                    if (SysVar.CodeSignNo == SysVar.DefineCompany.Welco_Desticon) return Type.GetType("WP.Customize.Desticon.Report," + "WP.Customize.Desticon", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.BuildingPlus) return Type.GetType("WP.Customize.BuildingPlus.Report," + "WP.Customize.BuildingPlus", true, true);

                    if (SysVar.CodeSignNo == SysVar.DefineCompany.IFP) return Type.GetType("WP.Customize.InterProForestProducts.Report," + "WP.Customize.InterProForestProducts", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.Matheus) return Type.GetType("WP.Customize.Matheus.Report," + "WP.Customize.Matheus", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.HallForest) return Type.GetType("WP.Customize.HallForest.Report," + "WP.Customize.HallForest", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.JHForest) return Type.GetType("WP.Customize.JHForest.Report," + "WP.Customize.JHForest", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.WestMark) return Type.GetType("WP.Customize.WestMark.Report," + "WP.Customize.WestMark", true, true);

                    if (SysVar.CodeSignNo == SysVar.DefineCompany.Gibbs) return Type.GetType("WP.Customize.Gibbs.Report," + "WP.Customize.Gibbs", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.FinestBrandFoods) return Type.GetType("WP.Customize.FinestBrandFoods.Report," + "WP.Customize.FinestBrandFoods", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.FoxLumber) return Type.GetType("WP.Customize.FoxLumber.Report," + "WP.Customize.FoxLumber", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.PetersonWoodTreating) return Type.GetType("WP.Customize.PetersonWoodTreating.Report," + "WP.Customize.PetersonWoodTreating", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.SouthernWoodPreserving) return Type.GetType("WP.Customize.SouthernWoodPreserving.Report," + "WP.Customize.SouthernWoodPreserving", true, true);
                    if (SysVar.CodeSignNo == SysVar.DefineCompany.StillCreek) return Type.GetType("WP.Customize.StillCreek.Report," + "WP.Customize.StillCreek", true, true);
                    //must be last line
                    //if (Customize.IsNuPro()) return Type.GetType("WP.Customize.LeKiu.Report," + "WP.Customize.LeKiu", true, true);
                    break;
            }
            return null;

        }

    }


    #endregion

    #region Customize EDI
    public class CustomizeEDIType
    {
        public static Type CurrentType()
        {
            if (SysVar.CodeSignNo == SysVar.DefineCompany.Mayfair) return Type.GetType("WP.Customize.Mayfair.EDI," + "WP.Customize.Mayfair", true, true);
            if (SysVar.CodeSignNo == SysVar.DefineCompany.ManionsSuperior || SysVar.CodeSignNo == SysVar.DefineCompany.ManionsStCloud) return Type.GetType("WP.Customize.Manions.EDI," + "WP.Customize.Manions", true, true);
            return null;
        }
        public static Type RSType()
        {


            if (CvtFunc.ToLeftString(SysVar.CodeSignNo, SysVar.DefineCompany.RockyTop.LastIndexOf('.')) == CvtFunc.ToLeftString(SysVar.DefineCompany.RockyTop, SysVar.DefineCompany.RockyTop.LastIndexOf('.'))) return Type.GetType("WP.Customize.RockyTop.EDI," + "WP.Customize.RockyTop", true, true);
            if (CvtFunc.ToLeftString(SysVar.CodeSignNo, SysVar.DefineCompany.EmpireCO.LastIndexOf('.')) == CvtFunc.ToLeftString(SysVar.DefineCompany.EmpireCO, SysVar.DefineCompany.EmpireCO.LastIndexOf('.'))) return Type.GetType("WP.Customize.Empire.EDI," + "WP.Customize.Empire", true, true);
            return null;
        }
    }
    #endregion




    #region include some function which need to be called by other module in order to reduce refrence
    public class ReflectMethod
    {

        public static bool ShowForm(string strFormName, FormStatus formStatus, long lRecId)
        {
            string strMenuId = "";
            MenuInfo miMenuInfo = new MenuInfo();

            strMenuId = DataFunctions.GetFieldValue("mMenu", "MenuID", "Net_ProgName='" + strFormName + "' and Net_Parameter=0");
            miMenuInfo = DataFunctions.GetMenuInfo(strMenuId);

            return ShowForm(miMenuInfo, formStatus, lRecId, false, null);
        }
        public static bool ShowForm(MenuInfo miMenuInfo)
        {
            return ShowForm(miMenuInfo, FormStatus.Delete, -1, false, null);
        }
        public static bool ShowForm(MenuInfo miMenuInfo, FormStatus formStatus, long lRecId)
        {
            return ShowForm(miMenuInfo, formStatus, lRecId, false, null);
        }

        public static string GetNameSpace(string strTableName)
        {

            if (strTableName.Substring(0, 1).ToLower() == "m")
                return "WP.MF.Form";
            else
                return "WP." + strTableName.Substring(0, 2).ToUpper() + ".Form";

        }

        public static bool ShowForm(MenuInfo miMenuInfo, FormStatus formStatus, long lRecId, bool bIsLookUp)
        {
            return ShowForm(miMenuInfo, formStatus, lRecId, bIsLookUp, null);
        }
        public static bool ShowForm(MenuInfo miMenuInfo, FormStatus formStatus, long lRecId, bool bIsLookUp, Form frmMDIForm)
        {
            bool bShowSuccess = false;
            string strMenuModule = "";
            string strEntryPassword = "";
            bool bNeedShowModal = false;
            Form frmForm;
            Form frmPassword;
            Type tpType;
            Type tpTypePassWord;
            string strNameSpace = "";
            PropertyInfo pInfo = null;
            MethodInfo mInfo = null;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                strNameSpace = miMenuInfo.strNameSpace;
                #region Create object Instance by Reflection method
                string sDir = Environment.CurrentDirectory;
                if (SysVar.CustomerName != "")
                {
                    tpType = Type.GetType(strNameSpace.Replace("WP.", "WP.Customize." + SysVar.CustomerName + ".") + "." + miMenuInfo.strProgname + "," + strNameSpace.Replace("WP.", "WP.Customize." + SysVar.CustomerName + "."), false, true);
                    if (tpType == null) tpType = Type.GetType(strNameSpace + "." + miMenuInfo.strProgname + "," + strNameSpace, false, true);
                }
                else
                {
                    tpType = Type.GetType(strNameSpace + "." + miMenuInfo.strProgname + "," + strNameSpace, false, true);
                }
                if (tpType == null && strNameSpace.Equals("WP.Modules") && miMenuInfo.strTableName.Length > 0)
                {
                    miMenuInfo.strNameSpace = GetNameSpace(miMenuInfo.strTableName);
                    strNameSpace = miMenuInfo.strNameSpace;
                    tpType = Type.GetType(strNameSpace + "." + miMenuInfo.strProgname + "," + strNameSpace, false, true);
                }
                if (tpType == null)
                {
                    MessageBox.Show(miMenuInfo.strProgname + " have not been done!", SysVar.WarnTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return false;
                }

                frmForm = (Form)System.Activator.CreateInstance(tpType);
                if (!BaseFunctions.ExistModalWindow()) { frmForm.MdiParent = (frmMDIForm != null ? frmMDIForm : SysVar.MDIParentForm); }
                frmForm.StartPosition = FormStartPosition.CenterScreen;

                #endregion

                #region set some property
                WP.Commons.SysVar.CurrentMenuInfo = miMenuInfo;
                pInfo = tpType.GetProperty("CurrentMenuInfo");
                if (pInfo != null) pInfo.SetValue(frmForm, miMenuInfo, null);
                if (frmForm.IsDisposed) return false;
                if (miMenuInfo.strTableName == "") miMenuInfo.strTableName = DataFunctions.GetFieldValue("mmenu", "TableName", "MenuId='" + miMenuInfo.strMenuId + "'");
                pInfo = tpType.GetProperty("TableName");
                if (pInfo != null && miMenuInfo.strTableName != "") pInfo.SetValue(frmForm, miMenuInfo.strTableName, null);

                if (formStatus != FormStatus.Delete)
                {
                    pInfo = tpType.GetProperty("CanSettingRecID");
                    if (pInfo != null) pInfo.SetValue(frmForm, false, null);
                }
                #region Show by password
                strEntryPassword = WP.Commons.Customize.GetEntryPassword(miMenuInfo);
                strEntryPassword = "";
                if (strEntryPassword != "")
                {
                    tpTypePassWord = Type.GetType("WP.Modules.frmEntryPassword, WP.Modules", false, true);
                    object[] Param = { strEntryPassword };
                    frmPassword = (Form)System.Activator.CreateInstance(tpTypePassWord, Param);
                    frmPassword.StartPosition = FormStartPosition.CenterScreen;

                    DialogResult dResult = frmPassword.ShowDialog();
                    if (DialogResult.OK != dResult)
                    {
                        frmForm.Dispose();
                        return false;
                    }
                }
                if (miMenuInfo.strTableName.Trim() == string.Empty) // not call by lookup modify by fy
                {
                    if (BaseFunctions.ExistModalWindow())
                    {
                        frmForm.TopLevel = true;
                        frmForm.MaximizeBox = false;
                    }
                    frmForm.Show();
                }
                else
                {
                    if (BaseFunctions.ExistModalWindow())
                    {
                        bNeedShowModal = true;
                    }
                    else
                        frmForm.Show();
                }

                #endregion
                if (formStatus != FormStatus.Delete)
                {
                    pInfo = tpType.GetProperty("CanSettingRecID");
                    if (pInfo != null) pInfo.SetValue(frmForm, true, null);

                    if (formStatus == FormStatus.AddNew)
                    {
                        pInfo = tpType.GetProperty("formStatus");
                        if (pInfo != null) pInfo.SetValue(frmForm, FormStatus.AddNew, null);

                    }
                    else if (formStatus == FormStatus.Update)
                    {
                        pInfo = tpType.GetProperty("RecID");
                        if (pInfo != null) pInfo.SetValue(frmForm, lRecId, null);
                    }

                }
                if (frmForm.IsDisposed)
                    return false;
                #endregion

                #region the method is for program 'frmedit'
                if (formStatus == FormStatus.AddNew)
                {

                    mInfo = tpType.GetMethod("AddNewRecord");
                    if (mInfo != null) mInfo.Invoke(frmForm, null);
                }
                else if (formStatus == FormStatus.Update)
                {
                    mInfo = tpType.GetMethod("EditRecord");
                    object[] Param = { lRecId };
                    if (mInfo != null) mInfo.Invoke(frmForm, Param);
                }
                #endregion

                if (bNeedShowModal)
                {
                    frmForm.MaximizeBox = false;
                    //frmForm.BringToFront();
                    frmForm.ShowDialog();
                }

                Application.DoEvents();
                bShowSuccess = true;
            }
            catch (Exception e)
            {
                bShowSuccess = false;
                ExceptionManager.ProcessException(e);
            }
            Cursor.Current = Cursors.Default;
            return bShowSuccess;

        }


        public static Form GetForm(MenuInfo miMenuInfo, bool bIsLookUp, out Size sizeNormal, out string strTableName)
        {

            string strMenuModule = "";
            Form frmForm;
            Type tpType;
            string strNameSpace = "";
            strTableName = "";
            sizeNormal = new Size(0, 0);
            EventInfo eInfo = null;
            PropertyInfo pInfo = null;
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                strNameSpace = miMenuInfo.strNameSpace;
                #region Create object Instance by Reflection method
                if (SysVar.CustomerName != "")
                {
                    tpType = Type.GetType(strNameSpace.Replace("WP.", "WP.Customize." + SysVar.CustomerName + ".") + "." + miMenuInfo.strProgname + "," + strNameSpace.Replace("WP.", "WP.Customize." + SysVar.CustomerName + "."), false, true);
                    if (tpType == null) tpType = Type.GetType(strNameSpace + "." + miMenuInfo.strProgname + "," + strNameSpace, false, true);
                }
                else
                {
                    tpType = Type.GetType(strNameSpace + "." + miMenuInfo.strProgname + "," + strNameSpace, false, true);
                }
                if (tpType == null)
                {
                    MessageBox.Show(miMenuInfo.strProgname + " have not been done!", SysVar.WarnTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return null;
                }

                frmForm = (Form)System.Activator.CreateInstance(tpType);
                sizeNormal = frmForm.Size;
                frmForm.MaximizeBox = false;
                frmForm.StartPosition = FormStartPosition.Manual;
                frmForm.Location = new Point(-10000, -10000);
                frmForm.Show();
                frmForm.Hide();


                #endregion

                #region set some property
                WP.Commons.SysVar.CurrentMenuInfo = miMenuInfo;
                pInfo = tpType.GetProperty("CurrentMenuInfo");
                if (pInfo != null) pInfo.SetValue(frmForm, miMenuInfo, null);

                if (miMenuInfo.strTableName == "") miMenuInfo.strTableName = DataFunctions.GetFieldValue("mmenu", "TableName", "MenuId='" + miMenuInfo.strMenuId + "'");
                pInfo = tpType.GetProperty("TableName");
                if (pInfo != null && miMenuInfo.strTableName != "") pInfo.SetValue(frmForm, miMenuInfo.strTableName, null);

                #endregion

                pInfo = tpType.GetProperty("TableName");
                if (pInfo != null)
                {
                    strTableName = pInfo.GetValue(frmForm, null).ToString();
                }
                return frmForm;

            }
            catch (Exception e)
            {
                ExceptionManager.ProcessException(e);
            }
            Cursor.Current = Cursors.Default;
            return null;
        }
        public static Type GetReportType(SystemModules modinfo, string strMethodName)
        {

            Type tpDefType = Type.GetType("WP." + modinfo.ToString() + ".Report.Print,WP." + modinfo.ToString() + ".Report", true, true);
            if (SysVar.CustomerName != "")
            {
                Type tpType = Type.GetType("WP.Customize." + SysVar.CustomerName + "." + modinfo.ToString() + ".Report.Print,WP.Customize." + SysVar.CustomerName + "." + modinfo.ToString() + ".Report", false, true);
                if (tpType != null)
                {
                    object obj = System.Activator.CreateInstance(tpType);
                    System.Reflection.MethodInfo mInfo = obj.GetType().GetMethod(strMethodName);
                    if (mInfo != null) return tpType;
                }
            }
            return tpDefType;

        }

        public static bool frmGridPublic_FieldCheck(string TableName, DataRow dr)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(DataRow), 1);

            string strNamedSpace = " WP.MF.BusinessRule";
            Type typeGridPublicBLL = Type.GetType(strNamedSpace + ".GridPublicBRL," + strNamedSpace, true, true);
            if (typeGridPublicBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeGridPublicBLL);
                string strMethod = "FieldCheck";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { TableName, dr };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool frmGridPublic_UpdateGridTable(DBAccess dBAccess, string TableName, DataRow dr)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(DataRow), 2);

            string strNamedSpace = " WP.MF.BusinessLogical";
            Type typeGridPublicBLL = Type.GetType(strNamedSpace + ".GridPublicBLL," + strNamedSpace, true, true);
            if (typeGridPublicBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeGridPublicBLL);
                string strMethod = "UpdateGridTable";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dBAccess, TableName, dr };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static void frmGlInterfaceRpt_PostGintf(string strModule, long lJnlNo, string strCondition, bool blnPrintPriview)
        {
            frmGlInterfaceRpt_PostGintf(null, strModule, lJnlNo, strCondition, blnPrintPriview, false, "");
        }
        public static void frmGlInterfaceRpt_PostGintf(string strModule, long lJnlNo, string strCondition, bool blnPrintPriview, bool blnNotDispRpt)
        {
            frmGlInterfaceRpt_PostGintf(null, strModule, lJnlNo, strCondition, blnPrintPriview, blnNotDispRpt, "");
        }
        public static void frmGlInterfaceRpt_PostGintf(DBAccess dbcon, string strModule, long lJnlNo, string strCondition, bool blnPrintPriview, bool blnNotDispRpt)
        {
            frmGlInterfaceRpt_PostGintf(dbcon, strModule, lJnlNo, strCondition, blnPrintPriview, blnNotDispRpt, "");
        }
        public static void frmGlInterfaceRpt_PostGintf(string strModule, long lJnlNo, string strCondition, bool blnPrintPriview, bool blnNotDispRpt, string strPrintName)
        {
            frmGlInterfaceRpt_PostGintf(null, strModule, lJnlNo, strCondition, blnPrintPriview, blnNotDispRpt, strPrintName);
        }
        public static void frmGlInterfaceRpt_PostGintf(DBAccess dbcon, string strModule, long lJnlNo, string strCondition, bool blnPrintPriview, bool blnNotDispRpt, string strPrintName)
        {
            object obj = null;
            Type[] ptype = new Type[7];
            bool bNoMsg = true;
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(long), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(bool), 4);
            ptype.SetValue(typeof(bool), 5);
            ptype.SetValue(typeof(string), 6);
            Type typefrmGlInterfaceRpt = Type.GetType("WP.GL.Form.frmGlInterfaceRpt," + "WP.GL.Form", true, true);
            if (typefrmGlInterfaceRpt != null)
            {
                object[] pcParam = { bNoMsg };
                object oRpt = System.Activator.CreateInstance(typefrmGlInterfaceRpt, pcParam);
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod("PostGintf", ptype);
                object[] Param = { dbcon, strModule, lJnlNo, strCondition, blnPrintPriview, blnNotDispRpt, strPrintName };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                }
            }
        }
        #region gl sub-ledger
        public static bool Update_GlSubDtl(System.Data.DataRow drSubDtl, string strUpdateTable)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            ptype.SetValue(typeof(string), 1);

            string strNamedSpace = " WP.GL.BusinessLogical";
            Type typeGlSubDtlBLL = Type.GetType(strNamedSpace + ".GlSubDtlBLL," + strNamedSpace, true, true);
            if (typeGlSubDtlBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeGlSubDtlBLL);
                string strMethod = "InsertSubDtl";
                if (CvtFunc.ToInt(drSubDtl["RecId"]) > 0) strMethod = "UpdateSubDtl";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drSubDtl, strUpdateTable };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_GlSubDtl(string strHdrSeqNo, string strDtlSeqNo, string strRecID, string strUpdateTable)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);

            string strNamedSpace = "WP.GL.BusinessLogical";
            Type typeGlSubDtlBLL = Type.GetType(strNamedSpace + ".GlSubDtlBLL," + strNamedSpace, true, true);
            if (typeGlSubDtlBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeGlSubDtlBLL);
                string strMethod = "DeleteSubGL";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strHdrSeqNo, strDtlSeqNo, strRecID, strUpdateTable };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        #endregion
        #region check customer remark when confirm sales order
        public static void LookUpCustRmk(string strCustNo, CustomerRmkLookUpType type, string strContactName)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(CustomerRmkLookUpType), 1);
            ptype.SetValue(typeof(string), 2);

            string strNamedSpace = "WP.OE.Form";
            Type otypeBLL = Type.GetType(strNamedSpace + ".frmOeCustRemarkQry," + strNamedSpace, true, true);
            if (otypeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(otypeBLL);
                string strMethod = "LookCustRmk";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strCustNo, type, strContactName };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                }
            }
        }
        #endregion
        #region In tally
        public static bool SetOutTally(string strItemNo, string strLocNo, string strDocNo, long lSeqNo, TallyOutModuleType moduleType, FormStatus formstatus, string strDefUnit, string strGRN, bool blnAutoSeleTally, int iDtlSeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[10];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(long), 3);
            ptype.SetValue(typeof(TallyOutModuleType), 4);
            ptype.SetValue(typeof(FormStatus), 5);
            ptype.SetValue(typeof(string), 6);
            ptype.SetValue(typeof(string), 7);
            ptype.SetValue(typeof(bool), 8);
            ptype.SetValue(typeof(int), 9);

            string strNamedSpace = "WP.Modules";
            Type otypeBLL = Type.GetType(strNamedSpace + ".frmOutTally," + strNamedSpace, true, true);
            if (otypeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(otypeBLL);
                string strMethod = "SetTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strItemNo, strLocNo, strDocNo, lSeqNo, moduleType, formstatus, strDefUnit, strGRN, blnAutoSeleTally, 0 };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool SetInTally(string strItemNo, string strLocNo, string strDocNo, long lSeqNo, TallyInModuleType moduleType, FormStatus formstatus, string strDefUnit, string strGRN, bool blnAutoSeleTally)
        {
            return SetInTally(strItemNo, strLocNo, strDocNo, lSeqNo, moduleType, formstatus, strDefUnit, strGRN, blnAutoSeleTally, string.Empty, 0);
        }
        public static bool SetInTally(string strItemNo, string strLocNo, string strDocNo, long lSeqNo, TallyInModuleType moduleType, FormStatus formstatus, string strDefUnit, string strGRN, bool blnAutoSeleTally, string strOeInvNo, long lngOeSeqno)
        {

            object obj = null;
            Type[] ptype = new Type[11];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(long), 3);
            ptype.SetValue(typeof(TallyInModuleType), 4);
            ptype.SetValue(typeof(FormStatus), 5);
            ptype.SetValue(typeof(string), 6);
            ptype.SetValue(typeof(string), 7);
            ptype.SetValue(typeof(bool), 8);
            ptype.SetValue(typeof(string), 9);
            ptype.SetValue(typeof(long), 10);

            string strNamedSpace = "WP.Modules";
            Type otypeBLL = Type.GetType(strNamedSpace + ".frmInTally," + strNamedSpace, true, true);
            if (otypeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(otypeBLL);
                string strMethod = "SetTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strItemNo, strLocNo, strDocNo, lSeqNo, moduleType, formstatus, strDefUnit, strGRN, blnAutoSeleTally, strOeInvNo, lngOeSeqno };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Update_OeReturnTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeOeReturnHdrBLL = Type.GetType(strNamedSpace + ".OeReturnHdrBLL," + strNamedSpace, true, true);
            if (typeOeReturnHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeOeReturnHdrBLL);
                string strMethod = "InsertQtyReturnedTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateQtyReturnedTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Update_PurchaseTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertPruchaseTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdatePruchaseTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_PurchaseTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);

            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeletePruchaseTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Delete_OeReturnTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeOeReurnHdrBLL = Type.GetType(strNamedSpace + ".OEReturnHdrBLL," + strNamedSpace, true, true);
            if (typeOeReurnHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeOeReurnHdrBLL);
                string strMethod = "DeleteQtyReturnedTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Update_GoodsRecvTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertGoodsRecvTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateGoodsRecvTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_GoodsRecvTally(string strDocNo, int iSeqNo, int iTallySeqNo, string strGRN)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(string), 3);

            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {

                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteGoodsRecvTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo, strGRN };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }


        public static bool Update_ProductRecvTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImInvProdHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertProdRecvTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateProdRecvTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_ProductRecvTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImInvProdHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {

                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteProdRecvTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_ProductIssuesTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImInvProdIssuesHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertProductIssuesTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateProductIssuesTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_ProductIssuesTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(string), 3);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImInvProdIssuesHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {

                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteProductIssuesTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_ImOpenBalanceTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = " WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImInvOpenBalHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertImOpenBalanceTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateImOpenBalanceTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_ImOpenBalanceTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            string strNamedSpace = " WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImInvOpenBalHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteImOpenBalanceTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static bool Update_RmOutputTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = " WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertRmOutputTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateRmOutputTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_RmOutputTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            string strNamedSpace = " WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteRmOutputTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static bool Update_OeOrderHdr(DBAccess dBAccess, System.Data.DataRow dr)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(System.Data.DataRow), 1);
            string strNamedSpace = "WP.OE.DataAccess";
            Type typeOeOrderDAL = Type.GetType(strNamedSpace + ".OeOrderHdrDAL," + strNamedSpace, true, true);
            if (typeOeOrderDAL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeOeOrderDAL);
                string strMethod = "UpdateOeOrderHdr";
                //if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateOEQuoteTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dBAccess, dr };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return true;
                }
            }
            return false;
        }

        public static bool Update_OEQuoteTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeOeQuoteHdrBLL = Type.GetType(strNamedSpace + ".OeQuoteHdrBLL," + strNamedSpace, true, true);
            if (typeOeQuoteHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeOeQuoteHdrBLL);
                string strMethod = "InsertOEQuoteTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateOEQuoteTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_OEQuoteTally(string strDocNo, int iSeqNo, int iTallySeqNo, bool bIsTrf)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(bool), 3);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeOeQuoteHdrBLL = Type.GetType(strNamedSpace + ".OeQuoteHdrBLL," + strNamedSpace, true, true);
            if (typeOeQuoteHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeOeQuoteHdrBLL);
                string strMethod = "DeleteOEQuoteTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo, bIsTrf };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Update_OEBidSectionDtlTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeBLL = Type.GetType(strNamedSpace + ".OEBidMasterBLL," + strNamedSpace, true, true);
            if (typeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeBLL);
                string strMethod = "InsertOEBidSectionTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateOEBidSectionTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_OEBidSectionDtlTally(string strDocNo, long lSectionSeqNo, long lSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(long), 1);
            ptype.SetValue(typeof(long), 2);
            ptype.SetValue(typeof(int), 3);


            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeBLL = Type.GetType(strNamedSpace + ".OEBidMasterBLL," + strNamedSpace, true, true);
            if (typeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeBLL);
                string strMethod = "DeleteOEBidSectionTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, lSectionSeqNo, lSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Update_OeBidJobControlSectionDtlTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeBLL = Type.GetType(strNamedSpace + ".OEBidJobControlHdrBLL," + strNamedSpace, true, true);
            if (typeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeBLL);
                string strMethod = "InsertOeBidJobControlSectionTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateOeBidJobControlSectionTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Update_OeBidJobControlSectionDtlBtoBTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeBLL = Type.GetType(strNamedSpace + ".OEBidJobControlHdrBLL," + strNamedSpace, true, true);
            if (typeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeBLL);
                string strMethod = "InsertOeBidJobControlSectionBtoBTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateOeBidJobControlSectionBtoBTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_OeBidJobControlSectionDtlTally(string strDocNo, long lSectionSeqNo, long lSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(long), 1);
            ptype.SetValue(typeof(long), 2);
            ptype.SetValue(typeof(int), 3);


            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeBLL = Type.GetType(strNamedSpace + ".OeBidJobControlHdrBLL," + strNamedSpace, true, true);
            if (typeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeBLL);
                string strMethod = "DeleteOeBidJobControlSectionTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, lSectionSeqNo, lSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Delete_OeBidJobControlSectionDtlBtoBTally(string strDocNo, long lSectionSeqNo, long lSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(long), 1);
            ptype.SetValue(typeof(long), 2);
            ptype.SetValue(typeof(int), 3);


            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typeBLL = Type.GetType(strNamedSpace + ".OeBidJobControlHdrBLL," + strNamedSpace, true, true);
            if (typeBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typeBLL);
                string strMethod = "DeleteOeBidJobControlSectionBtoBTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, lSectionSeqNo, lSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        #endregion
        #region out tally
        public static bool Update_SalesOrderQtyShipTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertSalesOrderQtyShipTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateSalesOrderQtyShipTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_SalesOrderQtyShipTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteSalesOrderQtyShipTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_OrderSubstituteQtyShipTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertOrderSubstituteQtyShipTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateOrderSubstituteQtyShipTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_OrderSubstituteQtyShipTally(string strDocNo, int iSeqNo, int iTallySeqNo, int iDtlSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(int), 3);


            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteOrderSubstituteQtyShipTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo, iDtlSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_RMInputTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertRMInputTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateRMInputTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_RMInputTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);

            string strNamedSpace = "WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteRmInputTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_IMTransferTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertTransferTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateTransferTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_IMTransferTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteTransferTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        #endregion

        #region Select non-stocking item

        public static bool Update_RemanForNonStockingItem(System.Data.DataRow dr)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertSalesOrderQtyShipForNonStockingItem";
                if (CvtFunc.ToInt(dr["RecId"]) > 0) strMethod = "UpdateSalesOrderQtyShipForNonStockingItem";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dr };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static bool Update_SalesOrderQtyShipForNonStockingItem(System.Data.DataRow dr)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertSalesOrderQtyShipForNonStockingItem";
                if (CvtFunc.ToInt(dr["RecId"]) > 0) strMethod = "UpdateSalesOrderQtyShipForNonStockingItem";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dr };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static bool Delete_RemanForNonStockingItem(int iRecID)
        {

            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(int), 0);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteSalesOrderQtyShipForNonStockingItem";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { iRecID };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Delete_SalesOrderQtyShipForNonStockingItem(int iRecID)
        {

            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(int), 0);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteSalesOrderQtyShipForNonStockingItem";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { iRecID };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_SalesReturnForNonStockingItem(System.Data.DataRow dr)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OEReturnHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertSalesOrderQtyShipForNonStockingItem";
                if (CvtFunc.ToInt(dr["RecId"]) > 0) strMethod = "UpdateSalesOrderQtyShipForNonStockingItem";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dr };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_SalesReturnForNonStockingItem(int iRecID)
        {

            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(int), 0);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OEReturnHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteSalesOrderQtyShipForNonStockingItem";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { iRecID };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        #endregion


        public static bool Update_IMAdjustTally(System.Data.DataRow drTally)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImAdjHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertAdjustTally";
                if (CvtFunc.ToInt(drTally["RecId"]) > 0) strMethod = "UpdateAdjustTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTally };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_IMAdjustTally(string strDocNo, int iSeqNo, int iTallySeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImAdjHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteAdjustTally";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static double CalcAdjCost_TotalCost(DBAccess dBAccess, string strItemNo, string strLocNo, string strTagNo, string strLotNo, double dblAdjCost, string strAdjCostUnit)
        {
            object obj = null;
            Type[] ptype = new Type[7];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(double), 5);
            ptype.SetValue(typeof(string), 6);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImAdjHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "CalcAdjCost_TotalCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dBAccess, strItemNo, strLocNo, strTagNo, strLotNo, dblAdjCost, strAdjCostUnit };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return double.Parse(obj.ToString());
                }
            }
            return 0;
        }
        public static double GetAdjCost(DBAccess dBAccess, string strItemNo, string strLocNo, string strTagNo, string strLotNo, double dblAdjAmt, string strAdjCostUnit)
        {
            object obj = null;
            Type[] ptype = new Type[7];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(double), 5);
            ptype.SetValue(typeof(string), 6);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImAdjHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "GetAdjCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dBAccess, strItemNo, strLocNo, strTagNo, strLotNo, dblAdjAmt, strAdjCostUnit };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return double.Parse(obj.ToString());
                }
            }
            return 0;
        }
        public static double CalcAdjQty_TotalCost(DBAccess dBAccess, string strItemNo, string strLocNo, string strTagNo, string strLotNo, double dblAdjQty, string strAdjQtyUnit)
        {
            object obj = null;
            Type[] ptype = new Type[7];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(double), 5);
            ptype.SetValue(typeof(string), 6);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImAdjHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "CalcAdjQty_TotalCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dBAccess, strItemNo, strLocNo, strTagNo, strLotNo, dblAdjQty, strAdjQtyUnit };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return double.Parse(obj.ToString());
                }
            }
            return 0;
        }
        public static double GetAdjQty(DBAccess dBAccess, string strItemNo, string strLocNo, string strTagNo, string strLotNo, double dblAdjAmt, string strAdjQtyUnit)
        {
            object obj = null;
            Type[] ptype = new Type[7];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(double), 5);
            ptype.SetValue(typeof(string), 6);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImAdjHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "GetAdjQty";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dBAccess, strItemNo, strLocNo, strTagNo, strLotNo, dblAdjAmt, strAdjQtyUnit };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return double.Parse(obj.ToString());
                }
            }
            return 0;
        }

        #region extra cost
        public static bool Update_PurchaseExtrCost(System.Data.DataRow drExtraCost)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertPruchaseExtraCost";

                if (CvtFunc.ToInt(drExtraCost["RecId"]) > 0) strMethod = "UpdatePruchaseExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drExtraCost };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_PurchaseExtrCost(string strDocNo, int iSeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeletePruchaseExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_GoodsRecvExtrCost(System.Data.DataRow drExtraCost)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertGoodsRecvExtraCost";
                if (CvtFunc.ToInt(drExtraCost["RecId"]) > 0) strMethod = "UpdateGoodsRecvExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drExtraCost };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_GoodsRecvExtrCost(string strDocNo, int iSeqNo, string strGRN)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(string), 2);

            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteGoodsRecvExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, strGRN };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_RemanExtrCost(System.Data.DataRow drExtraCost)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = " WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertExtraCost";
                if (CvtFunc.ToInt(drExtraCost["RecId"]) > 0) strMethod = "UpdateExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drExtraCost };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_RemanExtrCost(string strDocNo, int iSeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = " WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static bool Update_SalesOrderExtrCost(System.Data.DataRow drExtraCost)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertSalesOrderExtraCost";
                if (CvtFunc.ToInt(drExtraCost["RecId"]) > 0) strMethod = "UpdateSalesOrderExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drExtraCost };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Update_SalesReturnExtrCost(System.Data.DataRow drExtraCost)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeReturnHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertReturnExtraCost";
                if (CvtFunc.ToInt(drExtraCost["RecId"]) > 0) strMethod = "UpdateReturnExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drExtraCost };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_SalesOrderExtrCost(string strDocNo, int iSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);


            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteSalesOrderExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Delete_SalesReturnExtrCost(string strDocNo, int iSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);


            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeReturnHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteReturnExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static bool Update_IMTransferExtrCost(System.Data.DataRow drExtraCost)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertImTrfExtraCost";
                if (CvtFunc.ToInt(drExtraCost["RecId"]) > 0) strMethod = "UpdateImTrfExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drExtraCost };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_IMTransferExtrCost(string strRecID)
        {

            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(string), 0);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteImTrfExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strRecID };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        #endregion

        public static bool Update_QuoteExtrCost(System.Data.DataRow drExtraCost)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeQuoteHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertOeQuoteExtraCost";
                if (CvtFunc.ToInt(drExtraCost["RecId"]) > 0) strMethod = "UpdateOeQuoteExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drExtraCost };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Update_DetailOfApOpeningBalance(DBAccess dbAccess, int intRecID, DataRow drDtl, int intParameter)
        {
            object obj = null;
            object UpdateDtl = null;
            System.Reflection.MethodInfo mInfo = null;
            Type[] pType = new Type[3];
            pType.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
            pType.SetValue(typeof(DataRow), 1);
            pType.SetValue(typeof(int), 2);
            Type TypeForm = Type.GetType("WP.AP.DataAccess.ApOpenBalHdrDAL," + "WP.AP.DataAccess", true, true);
            if (TypeForm != null)
            {
                UpdateDtl = System.Activator.CreateInstance(TypeForm);
                if (intRecID <= 0)
                {
                    mInfo = UpdateDtl.GetType().GetMethod("InsertApOpenBalDtl", pType);
                }
                else
                {
                    mInfo = UpdateDtl.GetType().GetMethod("UpdateApOpenBalDtl", pType);
                }
                object[] Param = { dbAccess, drDtl, intParameter };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(UpdateDtl, Param);
                }
            }
            return true;
        }
        public static bool Delete_DetailOfApOpeningBalance(DBAccess dbAccess, string strRecID)
        {
            object obj = null;
            object DelDtl = null;
            System.Reflection.MethodInfo mInfo = null;
            Type[] pType = new Type[2];
            pType.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
            pType.SetValue(typeof(string), 1);
            Type TypeForm = Type.GetType("WP.AP.DataAccess.ApOpenBalHdrDAL," + "WP.AP.DataAccess", true, true);
            if (TypeForm != null)
            {
                DelDtl = System.Activator.CreateInstance(TypeForm);
                mInfo = DelDtl.GetType().GetMethod("DeleteApOpenBalDtl", pType);
                object[] Param = { dbAccess, strRecID };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(DelDtl, Param);
                }
            }
            return true;
        }
        public static bool Delete_QuoteExtrCost(string strDocNo, int iSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeQuoteHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteOeQuoteExtraCost";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        #region TruckCharge
        public static bool Update_PurchaseTruckCharge(System.Data.DataRow drTruckCharge)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertPruchaseTruckCharge";
                if (CvtFunc.ToInt(drTruckCharge["RecId"]) > 0) strMethod = "UpdatePruchaseTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTruckCharge };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_PurchaseTruckCharge(string strDocNo, int iSeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeletePruchaseTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Update_GoodsRecvTruckCharge(System.Data.DataRow drTruckCharge)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertGoodsRecvTruckCharge";
                if (CvtFunc.ToInt(drTruckCharge["RecId"]) > 0) strMethod = "UpdateGoodsRecvTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTruckCharge };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_GoodsRecvTruckCharge(string strDocNo, int iSeqNo, string strGRN)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(string), 2);

            string strNamedSpace = "WP.PO.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".PoOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteGoodsRecvTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, strGRN };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Update_RemanTruckCharge(System.Data.DataRow drTruckCharge, bool blnIsReman)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            ptype.SetValue(typeof(bool), 1);
            string strNamedSpace = " WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertTruckCharge";
                if (CvtFunc.ToInt(drTruckCharge["RecId"]) > 0) strMethod = "UpdateTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTruckCharge, blnIsReman };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_RemanTruckCharge(string strDocNo, int iSeqNo, bool blnIsReman)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(bool), 2);
            string strNamedSpace = " WP.RM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".RmWKOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, blnIsReman };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Update_SalesOrderTruckCharge(System.Data.DataRow drTruckCharge)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertSalesOrderTruckCharge";
                if (CvtFunc.ToInt(drTruckCharge["RecId"]) > 0) strMethod = "UpdateSalesOrderTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTruckCharge };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Update_SalesReturnTruckCharge(System.Data.DataRow drTruckCharge)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeReturnHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertReturnTruckCharge";
                if (CvtFunc.ToInt(drTruckCharge["RecId"]) > 0) strMethod = "UpdateReturnTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTruckCharge };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_SalesOrderTruckCharge(string strDocNo, int iSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteSalesOrderTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Delete_SalesReturnTruckCharge(string strDocNo, int iSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeReturnHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteReturnTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static bool Update_IMTransferTruckCharge(System.Data.DataRow drTruckCharge)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertImTrfTruckCharge";
                if (CvtFunc.ToInt(drTruckCharge["RecId"]) > 0) strMethod = "UpdateImTrfTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTruckCharge };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }
        public static bool Delete_IMTransferTruckCharge(string strRecID)
        {

            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(string), 0);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteImTrfTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strRecID };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool Update_QuoteTruckCharge(System.Data.DataRow drTruckCharge)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Data.DataRow), 0);
            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeQuoteHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "InsertOeQuoteTruckCharge";
                if (CvtFunc.ToInt(drTruckCharge["RecId"]) > 0) strMethod = "UpdateOeQuoteTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { drTruckCharge };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static bool Delete_QuoteTruckCharge(string strDocNo, int iSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = "WP.OE.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeQuoteHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "DeleteOeQuoteTruckCharge";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        #endregion

        public static void InsertImInvLoc(DBAccess dBAccess, string strItemNo, string strLocNo)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(WP.DB.DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);

            string strNamedSpace = "WP.IM.DataAccess";

            Type typeImInvLocDAL = Type.GetType(strNamedSpace + ".ImInvLocDAL," + strNamedSpace, true, true);
            if (typeImInvLocDAL != null)
            {
                object oQry = System.Activator.CreateInstance(typeImInvLocDAL);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("InsertImInvLoc", ptype);
                object[] Param = { dBAccess, strItemNo, strLocNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }


        public static void OeLinkInvPO(string strOrdNo, int iSeqNo)
        {

            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);

            string strNamedSpace = "WP.PO.Form";
            Type oType = Type.GetType(strNamedSpace + ".frmPOInvLinkOe," + strNamedSpace, true, true);
            if (oType != null)
            {
                object oRpt = System.Activator.CreateInstance(oType);
                string strMethod = "ShowInvLinkPO";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strOrdNo, iSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);

                }
            }

        }




        public static void RecalcInterst()
        {
            string mstrImDailyInterestToCommCostFileName = "C:\\Program Files\\WoodPro Software Inc\\WoodPro InSight" + "\\ImDailyInterestToCommCost.XmL";
            DataTable dtDailyInterestToCommCost = new DataTable();
            // DebugXML("DirTest" + ".Xml", Environment.CurrentDirectory);
            dtDailyInterestToCommCost.ReadXml(mstrImDailyInterestToCommCostFileName);
            if (dtDailyInterestToCommCost.Rows.Count == 0)
            {
                mstrImDailyInterestToCommCostFileName = mstrImDailyInterestToCommCostFileName.ToUpper().Replace("C:", "D:");
                dtDailyInterestToCommCost.ReadXml(mstrImDailyInterestToCommCostFileName);
                if (dtDailyInterestToCommCost.Rows.Count == 0) return;
            }
            try
            {
                DataRow dr = dtDailyInterestToCommCost.Rows[0];

                string strConDB = CvtFunc.ToString(dr["ConnectString"]);
                string strRunTime = CvtFunc.ToString(dr["StartTime"]).TrimEnd();
                //if (!(DateTime.Parse(strRunTime).Hour == DateTime.Now.Hour && DateTime.Parse(strRunTime).Minute == DateTime.Now.Minute)) return;
                Type[] ptype = null;
                Type typeRecal = null;
                ptype = new Type[1];
                ptype.SetValue(typeof(string), 0);


                typeRecal = Type.GetType("WP.IM.DataAccess.ImDailyChrgInterestToCommCostDAL," + "WP.IM.DataAccess", true, true);
                if (typeRecal != null)
                {
                    object oRpt = Activator.CreateInstance(typeRecal);
                    MethodInfo mInfo = oRpt.GetType().GetMethod("DailyInterestToCommssionCostFromOverNight", ptype);
                    string[] strServerandDB = strConDB.Split(new string[] { "\r\n" } , StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strServerandDB.Length; i++)
                    {
                        object[] Param = { strServerandDB[i] };
                        if (mInfo != null)
                        {
                            object obj = mInfo.Invoke(oRpt, Param);
                            obj = null;
                            //this.timer1.Stop();
                            //System.Threading.Thread.Sleep(70000);
                            //this.timer1.Start();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //DebugXML("ErrorTest" + ".Xml", ex.Message);
            }
        }
        public static void frmArCustShortQry_ShowWimdows(bool blnCalledBy)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(bool), 0);

            Type typefrmArCustShortQry = Type.GetType("WP.AR.Form.frmArCustShortQry," + "WP.AR.Form", true, true);
            if (typefrmArCustShortQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArCustShortQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("ShowWimdows", ptype);
                object[] Param = { blnCalledBy };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }

        public static void frmArCustShortQry_ShowWimdows(MenuInfo menuInfo, int intSupType)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(MenuInfo), 0);
            ptype.SetValue(typeof(int), 1);

            Type typefrmArCustShortQry = Type.GetType("WP.AR.Form.frmArCustShortQry," + "WP.AR.Form", true, true);
            if (typefrmArCustShortQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArCustShortQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("ShowWimdows", ptype);
                object[] Param = { menuInfo, intSupType };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }

        public static void frmArAgedReceQry_QryCustAgedRecv(string strCustNo)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(string), 0);

            Type typefrmArAgedReceQry = Type.GetType("WP.AR.Form.frmArAgedReceQry," + "WP.AR.Form", true, true);
            if (typefrmArAgedReceQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArAgedReceQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("QryCustAgedRecv", ptype);
                object[] Param = { strCustNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
        public static void frmfrmArApInVenHisQry_ShowInvHist(string strCustNoOrSupNo, string strDocNo, int intLookUpType,
            bool blnFlag, string strgcNo, string strRtype, bool blnSeleType, string strTypeInvHist)
        {
            object obj = null;
            Type[] ptype = new Type[8];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(bool), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(string), 5);
            ptype.SetValue(typeof(bool), 6);
            ptype.SetValue(typeof(string), 7);

            Type typefrmArApInVenHisQry = Type.GetType("WP.AR.Form.frmArApInVenHisQry," + "WP.AR.Form", true, true);
            if (typefrmArApInVenHisQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArApInVenHisQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("ShowInvHist", ptype);
                object[] Param = { strCustNoOrSupNo, strDocNo, intLookUpType,
                                    blnFlag, strgcNo, strRtype, blnSeleType, strTypeInvHist };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
        public static void frmArAgedReceQry_QryCustAgedRecv(string strCustNo, string strCutOffDate, string strApplyTo)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);

            Type typefrmArAgedReceQry = Type.GetType("WP.AR.Form.frmArAgedReceQry," + "WP.AR.Form", true, true);
            if (typefrmArAgedReceQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArAgedReceQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("QryCustAgedRecv", ptype);
                object[] Param = { strCustNo, strCutOffDate, strApplyTo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }

        public static void frmArReceivableCashRecvQry_QryRecv(string strSlspNo, string strStDate, string strEdDate)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);

            Type typefrmArAgedReceQry = Type.GetType("WP.AR.Form.frmArReceivableCashRecvQry," + "WP.AR.Form", true, true);
            if (typefrmArAgedReceQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArAgedReceQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("QryRecv", ptype);
                object[] Param = { strSlspNo, strStDate, strEdDate };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }

        public static void frmArCustCreditQry_Reflect(string strCustNo)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(string), 0);

            Type typefrmArCustCreditQry = Type.GetType("WP.AR.Form.frmArCustCreditQry," + "WP.AR.Form", true, true);
            if (typefrmArCustCreditQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArCustCreditQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("QryCustCredit", ptype);
                object[] Param = { strCustNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
        public static void frmArCreditMtn_Reflect(string strRecID)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(bool), 1);

            Type typefrmArCreditMtn = Type.GetType("WP.AR.Form.frmArCreditMtn," + "WP.AR.Form", true, true);
            if (typefrmArCreditMtn != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArCreditMtn);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("EnterCreditManagement", ptype);
                object[] Param = { strRecID, true };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
        public static bool frmArMarkPaidInv_PaidAllInv(DBAccess dBAccess, DateTime dtDate)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(WP.DB.DBAccess), 0);
            ptype.SetValue(typeof(DateTime), 1);

            Type typefrmArMarkPaidInv = Type.GetType("WP.AR.Form.frmArMarkPaidInv," + "WP.AR.Form", true, true);
            if (typefrmArMarkPaidInv != null)
            {
                object oMark = System.Activator.CreateInstance(typefrmArMarkPaidInv);

                System.Reflection.MethodInfo mInfo = oMark.GetType().GetMethod("PaidAllInv", ptype);
                object[] Param = { dBAccess, dtDate };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oMark, Param);
                    return CvtFunc.ToBoolean(obj.ToString());
                }
            }
            return false;
        }

        public static void frmApAgedPayQryBySup_QrySupAgedRecv(string strSupno)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(string), 0);

            Type typefrmApAgedPayQryBySup = Type.GetType("WP.AP.Form.frmApAgedPayQryBySup," + "WP.AP.Form", true, true);
            if (typefrmApAgedPayQryBySup != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmApAgedPayQryBySup);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("QrySupAgedRecv", ptype);


                object[] Param = { strSupno };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }

        public static void frmApAccruPayInquiry_ShowWindow(int pID, string strSupNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(int), 0);
            ptype.SetValue(typeof(string), 1);

            Type typefrmApAccruPayInquiry = Type.GetType("WP.AP.Form.frmApAccruPayInquiry," + "WP.AP.Form", true, true);
            if (typefrmApAccruPayInquiry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmApAccruPayInquiry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("ShowWindow", ptype);

                object[] Param = { pID, strSupNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strCustNoOrSupNo"></param>
        /// <param name="strDocNo"></param>
        /// <param name="intLookUpType">  1 --------show be called by Ar Aged receivable inquiry.
        ///                               2 --------show be called by Ap Aged payable inquiry.</param>
        /// <param name="blnFlag">default false</param>
        /// <param name="strgcNo">""</param>
        /// <param name="strRtype">""</param>
        /// <param name="blnSeleType">default true</param>
        /// <param name="strTypeInvHist">""</param>
        public static void frmArApInVenHisQry_ShowInvHist(string strCustNoOrSupNo, string strDocNo, int intLookUpType,
            bool blnFlag, string strgcNo, string strRtype, bool blnSeleType, string strTypeInvHist)
        {
            object obj = null;
            Type[] ptype = new Type[8];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(bool), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(string), 5);
            ptype.SetValue(typeof(bool), 6);
            ptype.SetValue(typeof(string), 7);

            Type typefrmArApInVenHisQry = Type.GetType("WP.AR.Form.frmArApInVenHisQry," + "WP.AR.Form", true, true);
            if (typefrmArApInVenHisQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArApInVenHisQry);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("ShowInvHist", ptype);
                object[] Param = { strCustNoOrSupNo, strDocNo, intLookUpType,
                      blnFlag, strgcNo, strRtype, blnSeleType, strTypeInvHist };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
        public static string frmImItemCodeGen_ShowItemCodeGen(int intParameter, bool blnNeedReturnValue)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(int), 0);
            ptype.SetValue(typeof(bool), 1);
            Type typefrmImItemCodeGen = Type.GetType("WP.IM.Form.frmImItemCodeGen," + "WP.IM.Form", true, true);
            if (typefrmImItemCodeGen != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmImItemCodeGen);
                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("ShowItemCodeGen", ptype);
                object[] Param = { intParameter, blnNeedReturnValue };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                    return obj.ToString();
                }
            }
            return "";
        }

        public static string frmImInvAvlQrybyItem_SelectItem(ItemInventoryInquiryType QryType, string strItemNo, string strLocNo, string strType, string strDimension, string strStocking, bool blnQtyAvail, bool blnGrouping)
        {
            return frmImInvAvlQrybyItem_SelectItem(QryType, strItemNo, strLocNo, strType, strDimension, strStocking, blnQtyAvail, blnGrouping, true, false, "", "", false, InventoryAvailQryCallType.Others, "");
        }
        public static string frmImInvAvlQrybyItem_SelectItem(ItemInventoryInquiryType QryType, string strItemNo, string strLocNo, string strType, string strDimension, string strStocking, bool blnQtyAvail, bool blnGrouping, bool blnMultSele)
        {
            return frmImInvAvlQrybyItem_SelectItem(QryType, strItemNo, strLocNo, strType, strDimension, strStocking, blnQtyAvail, blnGrouping, blnMultSele, false, "", "", false, InventoryAvailQryCallType.Others, "");
        }
        public static string frmImInvAvlQrybyItem_SelectItem(ItemInventoryInquiryType QryType, string strItemNo, string strLocNo, string strType, string strDimension, string strStocking, bool blnQtyAvail, bool blnGrouping, bool blnMultSele, bool blnNeedEnterQtyAndPrice, string strCustNo)
        {
            return frmImInvAvlQrybyItem_SelectItem(QryType, strItemNo, strLocNo, strType, strDimension, strStocking, blnQtyAvail, blnGrouping, blnMultSele, blnNeedEnterQtyAndPrice, strCustNo, "", false, InventoryAvailQryCallType.Others, "");
        }
        public static string frmImInvAvlQrybyItem_SelectItem(ItemInventoryInquiryType QryType, string strItemNo, string strLocNo, string strType, string strDimension, string strStocking, bool blnQtyAvail, bool blnGrouping, bool blnMultSele, bool blnNeedEnterQtyAndPrice, string strCustNo, string strTitle)
        {
            return frmImInvAvlQrybyItem_SelectItem(QryType, strItemNo, strLocNo, strType, strDimension, strStocking, blnQtyAvail, blnGrouping, blnMultSele, blnNeedEnterQtyAndPrice, strCustNo, strTitle, false, InventoryAvailQryCallType.Others, "");
        }
        public static string frmImInvAvlQrybyItem_SelectItem(ItemInventoryInquiryType QryType, string strItemNo, string strLocNo, string strType, string strDimension, string strStocking, bool blnQtyAvail, bool blnGrouping, bool blnMultSele, bool blnNeedEnterQtyAndPrice, string strCustNo, string strTitle, bool blnCanNotSeePriceAndCost, InventoryAvailQryCallType callType)
        {
            return frmImInvAvlQrybyItem_SelectItem(QryType, strItemNo, strLocNo, strType, strDimension, strStocking, blnQtyAvail, blnGrouping, blnMultSele, blnNeedEnterQtyAndPrice, strCustNo, strTitle, blnCanNotSeePriceAndCost, callType, "");
        }
        public static string frmImInvAvlQrybyItem_SelectItem(ItemInventoryInquiryType QryType, string strItemNo, string strLocNo, string strType, string strDimension, string strStocking, bool blnQtyAvail, bool blnGrouping, bool blnMultSele, bool blnNeedEnterQtyAndPrice, string strCustNo, string strTitle, bool blnCanNotSeePriceAndCost, InventoryAvailQryCallType callType, string strPriceGroupNo)
        {
            object obj = null;
            Type[] ptype = new Type[15];
            ptype.SetValue(typeof(ItemInventoryInquiryType), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(string), 5);
            ptype.SetValue(typeof(bool), 6);
            ptype.SetValue(typeof(bool), 7);
            ptype.SetValue(typeof(bool), 8);
            ptype.SetValue(typeof(bool), 9);
            ptype.SetValue(typeof(string), 10);
            ptype.SetValue(typeof(string), 11);
            ptype.SetValue(typeof(bool), 12);
            ptype.SetValue(typeof(InventoryAvailQryCallType), 13);
            ptype.SetValue(typeof(string), 14);
            Type typefrmImInvAvlQrybyItem = Type.GetType("WP.IM.Form.frmImInvAvlQry," + "WP.IM.Form", true, true);
            if (typefrmImInvAvlQrybyItem != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmImInvAvlQrybyItem);
                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("SelectItem", ptype);
                object[] Param = { QryType, strItemNo, strLocNo, strType, strDimension, strStocking, blnQtyAvail, blnGrouping, blnMultSele, blnNeedEnterQtyAndPrice, strCustNo, strTitle, blnCanNotSeePriceAndCost, callType, strPriceGroupNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                    return obj.ToString();
                }
            }
            return "";
        }

        public static void frmImInvAvlQrybyItem_ShowFrm(ItemInventoryInquiryType QryType, Control con)
        {
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(ItemInventoryInquiryType), 0);
            ptype.SetValue(typeof(System.Windows.Forms.Control), 1);

            Type typeObj = null;
            typeObj = Type.GetType("WP.IM.Form.frmImInvAvlQry," + "WP.IM.Form", true, true);

            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowImInvAvlQry", ptype);
                object[] Param = { QryType, con };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmImInvAvlQrybyItem_CloseFrm(Control conTabControl)
        {
            Type[] ptype = new Type[1];
            Type typeObj = null;
            Form frmQry = null;

            ptype.SetValue(typeof(System.Windows.Forms.Control), 0);
            typeObj = Type.GetType("WP.IM.Form.frmImInvAvlQry," + "WP.IM.Form", true, true);

            if (typeObj != null)
            {
                foreach (Control conTabPage in conTabControl.Controls)
                {
                    if (conTabPage.GetType().ToString() == "System.Windows.Forms.TabPage")
                    {
                        foreach (Control con in conTabPage.Controls)
                        {
                            if (con.Name == "frmImInvAvlQry")
                            {
                                frmQry = con as Form;
                                if (frmQry != null) frmQry.Close();
                            }
                        }
                    }
                }
            }
        }
        public static void frmImInvAvlQrybyItem_Query(Control conTabPage, string strCustNo)
        {
            Type[] ptype = new Type[1];
            Type typeObj = null;

            ptype.SetValue(typeof(string), 0);
            typeObj = Type.GetType("WP.IM.Form.frmImInvAvlQry," + "WP.IM.Form", true, true);

            if (typeObj != null)
            {
                foreach (Control con in conTabPage.Controls)
                {
                    if (con.Name == "frmImInvAvlQry")
                    {
                        System.Reflection.MethodInfo mInfo = con.GetType().GetMethod("ShowQryByCust", ptype);
                        object[] Param = { strCustNo };
                        if (mInfo != null)
                        {
                            mInfo.Invoke(con, Param);
                        }
                    }
                }
            }
        }

        public static string frmOeSelectItemByContractPrice_SelectItem(string strCustNo, string strItemNo, string strLocNo, string strType, string strDimension, string strStocking, bool blnQtyAvail, bool blnGrouping)
        {
            object obj = null;
            Type[] ptype = new Type[8];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(string), 5);
            ptype.SetValue(typeof(bool), 6);
            ptype.SetValue(typeof(bool), 7);


            Type typefrmOeSelectItemByContractPrice = Type.GetType("WP.OE.Form.frmOeSelectItemByContractPrice," + "WP.OE.Form", true, true);
            if (typefrmOeSelectItemByContractPrice != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmOeSelectItemByContractPrice);
                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("SelectItem", ptype);
                object[] Param = { strCustNo, strItemNo, strLocNo, strType, strDimension, strStocking, blnQtyAvail, blnGrouping };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                    return obj.ToString();
                }
            }
            return "";
        }
        public static string frmImInvAvailQryCategory_SelectItem(string strItemNo, string strLocNo)
        {
            return frmImInvAvailQryCategory_SelectItem(strItemNo, strLocNo, "", true, false, SelectItemByCategoryCallType.Others);
        }

        public static string frmImInvAvailQryCategory_SelectItem(string strItemNo, string strLocNo, string strCustNo, bool blnNeedEnterQtyAndPrice, bool blnCanNotSeePriceAndCost, SelectItemByCategoryCallType calltype)
        {
            object obj = null;
            Type[] ptype = new Type[6];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(bool), 3);
            ptype.SetValue(typeof(bool), 4);
            ptype.SetValue(typeof(SelectItemByCategoryCallType), 5);
            Type typefrmImInvAvailQryCategory = Type.GetType("WP.IM.Form.frmImInvAvailQryCategory," + "WP.IM.Form", true, true);
            if (typefrmImInvAvailQryCategory != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmImInvAvailQryCategory);
                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("SelectItem", ptype);
                object[] Param = { strItemNo, strLocNo, strCustNo, blnNeedEnterQtyAndPrice, blnCanNotSeePriceAndCost, calltype };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                    return obj.ToString();
                }
            }
            return "";
        }


        public static string frmImInvAvlForOeSalesQry_SelectItem(string strItemNo, string strLocNo, string strPlnNo,
                        string strStocking, bool blnQtyAvail,
                        bool blnGrouping)
        {
            return frmImInvAvlForOeSalesQry_SelectItem(strItemNo, strLocNo, strPlnNo, strStocking, blnQtyAvail, blnGrouping, true);
        }

        public static string frmImInvAvlForOeSalesQry_SelectItem(string strItemNo, string strLocNo, string strPlnNo,
                                string strStocking, bool blnQtyAvail,
                                bool blnGrouping, bool blnMultSele)
        {
            object obj = null;
            Type[] ptype = new Type[7];

            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(bool), 4);
            ptype.SetValue(typeof(bool), 5);
            ptype.SetValue(typeof(bool), 6);

            Type typefrmImInvAvlForOeSalesQry = Type.GetType("WP.IM.Form.frmImInvAvlForOeSalesQry," + "WP.IM.Form", true, true);
            if (typefrmImInvAvlForOeSalesQry != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmImInvAvlForOeSalesQry);
                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("SelectItem", ptype);
                object[] Param = { strItemNo, strLocNo, strPlnNo, strStocking, blnQtyAvail, blnGrouping, blnMultSele };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                    return obj.ToString();
                }
            }
            return "";
        }
        public static string frmImInvAvlQryByBuyer_SelectItem(string strItemNo, string strLocNo, string strPlnNo,
                        string strStocking, bool blnQtyAvail,
                        bool blnGrouping)
        {
            return frmImInvAvlQryByBuyer_SelectItem(strItemNo, strLocNo, strPlnNo, strStocking, blnQtyAvail, blnGrouping, true);
        }

        public static string frmImInvAvlQryByBuyer_SelectItem(string strItemNo, string strLocNo, string strPlnNo,
                                string strStocking, bool blnQtyAvail,
                                bool blnGrouping, bool blnMultSele)
        {
            object obj = null;
            Type[] ptype = new Type[7];

            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(bool), 4);
            ptype.SetValue(typeof(bool), 5);
            ptype.SetValue(typeof(bool), 6);

            Type typefrmImInvAvlQryByBuyer = Type.GetType("WP.IM.Form.frmImInvAvlQryByBuyer," + "WP.IM.Form", true, true);
            if (typefrmImInvAvlQryByBuyer != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmImInvAvlQryByBuyer);
                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("SelectItem", ptype);
                object[] Param = { strItemNo, strLocNo, strPlnNo, strStocking, blnQtyAvail, blnGrouping, blnMultSele };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                    return obj.ToString();
                }
            }
            return "";
        }
        public static void frmApAgedPayQrySum_QrySupAgedRecv(string strCutOffDate, bool blnPosted, bool blnUnPaid, string strCurNo, bool blnAgedByDocDate)
        {
            object obj = null;
            Type[] ptype = new Type[5];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(bool), 1);
            ptype.SetValue(typeof(bool), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(bool), 4);

            Type typefrmApAgedPayQrySum = Type.GetType("WP.AP.Form.frmApAgedPayQrySum," + "WP.Ap.Form", true, true);
            if (typefrmApAgedPayQrySum != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmApAgedPayQrySum);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("QrySupAgedRecv", ptype);
                object[] Param = { strCutOffDate, blnPosted, blnUnPaid,
                      strCurNo, blnAgedByDocDate };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
        public static void frmArAgedReceQrySum_QryCustAgedRecv(string strCutOffDate, bool blnPosted, bool blnUnPaid, bool blnIncludeInterest, string strCurNo, bool blnAgedByDocDate)
        {
            object obj = null;
            Type[] ptype = new Type[6];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(bool), 1);
            ptype.SetValue(typeof(bool), 2);
            ptype.SetValue(typeof(bool), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(bool), 5);

            Type typefrmArAgedReceQrySum = Type.GetType("WP.AR.Form.frmArAgedReceQrySum," + "WP.Ar.Form", true, true);
            if (typefrmArAgedReceQrySum != null)
            {
                object oQry = System.Activator.CreateInstance(typefrmArAgedReceQrySum);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("QryCustAgedRecv", ptype);
                object[] Param = { strCutOffDate, blnPosted, blnUnPaid,blnIncludeInterest,
                      strCurNo, blnAgedByDocDate };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }

        public static bool frmApPurgePaidInv_PaidAllInv(DBAccess dBAccess, DateTime dtDate)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(WP.DB.DBAccess), 0);
            ptype.SetValue(typeof(DateTime), 1);

            Type typefrmApPurgePaidInv = Type.GetType("WP.AP.Form.frmApPurgePaidInv," + "WP.AP.Form", true, true);
            if (typefrmApPurgePaidInv != null)
            {
                object oPurge = System.Activator.CreateInstance(typefrmApPurgePaidInv);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("PaidAllInv", ptype);
                object[] Param = { dBAccess, dtDate };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oPurge, Param);
                    return CvtFunc.ToBoolean(obj.ToString());
                }
            }
            return false;
        }
        public static void frmPoPurchaseQry_ShowOnOrder(string strItemNo, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.PO.Form.frmPoPurchaseQry," + "WP.PO.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowOnOrder", ptype);
                object[] Param = { strItemNo, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmOeBackOrderQryByItem_ShowBackOrder(string strItemNo, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.OE.Form.frmOeBackOrderQryByItemNo," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowBackOrderByItem", ptype);
                object[] Param = { strItemNo, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmOeCustSrvQry_Custsrvqry(string strCustNo)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(string), 0);

            Type typeObj = Type.GetType("WP.OE.Form.frmOeCustSrvQry," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("Custsrvqry", ptype);
                object[] Param = { strCustNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmOeMillOfferQry_InputeTally(bool blnIsInputeTally, string strOeOrdNo, string strItemNo, long lngSeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(bool), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(long), 3);

            Type typeObj = Type.GetType("WP.OE.Form.frmOeMillOfferQry," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("InputeTally", ptype);
                object[] Param = { blnIsInputeTally, strOeOrdNo, strItemNo, lngSeqNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmOeMillOfferQry_ShowMeFromOE(bool blnIsFromOE, string strOeOrdNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(bool), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.OE.Form.frmOeMillOfferQry," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowMeFromOE", ptype);
                object[] Param = { blnIsFromOE, strOeOrdNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }


        public static void frmOEQuoteRemainingQry_ShowCommitted(string strItemNo, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.OE.Form.frmOEQuoteRemainingQry," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowCommitted", ptype);
                object[] Param = { strItemNo, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmOEOrdInvByItemCustQry_ShowCommitted(string strItemNo, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.OE.Form.frmOEOrdInvByItemCustQry," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowCommitted", ptype);
                object[] Param = { strItemNo, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmRMQtyByItemQry_ShowRMQty(string strItemNo, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.RM.Form.frmRMQtyByItemQry," + "WP.RM.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowRMQty", ptype);
                object[] Param = { strItemNo, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmImTrfInOutQry_ShowTrfQty(string strItemNo, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.IM.Form.frmImTrfInOutQry," + "WP.IM.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowTrfQty", ptype);
                object[] Param = { strItemNo, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmImInvHistbyItemQry_QryItemQtyAvail(string strItemNo, bool blnOnlyQtyAvail, string strType, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(Boolean), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);

            Type typeObj = Type.GetType("WP.IM.Form.frmImInvHistbyItemQry," + "WP.IM.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("QryItemQtyAvail", ptype);
                object[] Param = { strItemNo, blnOnlyQtyAvail, strType, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmGlOpenFileQry_QueryOpenFile(string strStartDate, string strEndDate, string strAcct, string strProfit, string strBrn)
        {
            object obj = null;
            Type[] ptype = new Type[5];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 5);
            Type typeObj = Type.GetType("WP.GL.Form.frmGlOpenFileQry," + "WP.GL.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("QueryOpenFile", ptype);
                object[] Param = { strStartDate, strEndDate, strAcct, strProfit, strBrn };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmGlAccountQry_QueryOpenFile(string strStartDate, string strEndDate, string strAcct, string strProfit, string strBrn, bool bIsModal)
        {
            object obj = null;
            Type[] ptype = new Type[6];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(bool), 5);

            Type typeObj = Type.GetType("WP.GL.Form.frmGlAccountQry," + "WP.GL.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("QueryOpenFile", ptype);
                object[] Param = { strStartDate, strEndDate, strAcct, strProfit, strBrn, bIsModal };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmGlAccountQry_QueryOpenFile(string strStartDate, string strEndDate, string strAcct, string strProfit, string strBrn)
        {
            frmGlAccountQry_QueryOpenFile(strStartDate, strEndDate, strAcct, strProfit, strBrn, false);
        }
        public static bool frmGlReCalcAcctAmt_ReCalcAll(DBAccess dBAccess, string strStProfitNo, string strEdProfitNo)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(WP.DB.DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            Type typeObj = Type.GetType("WP.GL.Form.frmGlReCalcAcctAmt," + "WP.GL.Form", true, true);
            if (typeObj != null)
            {
                object oGl = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oGl.GetType().GetMethod("ReCalcAll", ptype);
                object[] Param = { dBAccess, strEdProfitNo, strEdProfitNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oGl, Param);
                    return CvtFunc.ToBoolean(obj.ToString());
                }
            }
            return false;
        }
        public static void frmMGLAccountQry_GetAcctNo(int intSumType)
        {
            object obj = null;
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(int), 0);
            Type typeObj = Type.GetType("WP.MF.Form.frmMGLAccountQry," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("GetAcctNo", ptype);
                object[] Param = { intSumType };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmGlFinaFormatQry_ShowFrm(Control con)
        {
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Windows.Forms.Control), 0);

            Type typeObj = Type.GetType("WP.GL.Form.frmGlFinaFormatQry," + "WP.GL.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj, null);
                System.Reflection.MethodInfo mInfo1 = oPurge.GetType().GetMethod("ShowQry", ptype);
                object[] Param1 = { con };
                if (mInfo1 != null)
                {
                    mInfo1.Invoke(oPurge, Param1);
                }
            }
        }


        public static void frmOeDailyRouteSummaryQry_ShowForm()
        {
            object obj = null;


            Type typeObj = Type.GetType("WP.OE.Form.frmOeDailyRouteSummaryQry," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm");
                object[] Param = null;
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }


        #region ImSlsHistQry ByItem ByCust BySlsp

        public static void frmImSlsHistByItemQry_QryItemQtyAvail(string strItemNo, bool blnOnlyQtyAvail, string strType, string strLocNo)
        {
            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(Boolean), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);

            Type typeObj = Type.GetType("WP.IM.Form.frmImSlsHistByItemQry," + "WP.IM.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("QryItemQtyAvail", ptype);
                object[] Param = { strItemNo, blnOnlyQtyAvail, strType, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmImSlsHistByCustQry_ShowFrm(PageTabMisc TabMisc, Control con)
        {
            Type[] ptype = new Type[1];
            ptype.SetValue(typeof(System.Windows.Forms.Control), 0);

            //Type[] typeObj = new Type[4];
            Type typeObj = null;
            switch (TabMisc)
            {
                case PageTabMisc.Detail:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryDetail," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.CateGory:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryCateGory," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.Monthly:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryMonthly," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.Yearly:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryYear," + "WP.IM.Form", true, true);
                    break;
            }
            if (typeObj != null)
            {
                object[] Param = { ImSlsHistQryType.ByCust };
                object oPurge = System.Activator.CreateInstance(typeObj, Param);
                System.Reflection.MethodInfo mInfo1 = oPurge.GetType().GetMethod("ShowSlsHistQryByCust", ptype);
                object[] Param1 = { con };
                if (mInfo1 != null)
                {
                    mInfo1.Invoke(oPurge, Param1);
                }
            }
        }
        public static void frmImSlsHistByCustQry_CloseFrm(PageTabMisc TabMisc, Control conTabControl)
        {
            Type[] ptype = new Type[1];
            Type typeObj = null;
            Form frmQry = null;

            ptype.SetValue(typeof(System.Windows.Forms.Control), 0);
            switch (TabMisc)
            {
                case PageTabMisc.Detail:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryDetail," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.CateGory:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryCateGory," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.Monthly:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryMonthly," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.Yearly:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryYear," + "WP.IM.Form", true, true);
                    break;
            }
            if (typeObj != null)
            {
                foreach (Control conTabPage in conTabControl.Controls)
                {
                    if (conTabPage.GetType().ToString() == "System.Windows.Forms.TabPage")
                    {
                        foreach (Control con in conTabPage.Controls)
                        {
                            if (con.Name == "frmImSlsHistQryDetail" || con.Name == "frmImSlsHistQryCateGory" ||
                                con.Name == "frmImSlsHistQryMonthly" || con.Name == "frmImSlsHistQryYear")
                            {
                                frmQry = con as Form;
                                if (frmQry != null) frmQry.Close();
                            }
                        }
                    }
                }
            }
        }
        public static void frmImSlsHistByCustQry_Query(Control conTabPage, PageTabMisc TabMisc, string strCustNo)
        {
            Type[] ptype = new Type[1];
            Type typeObj = null;

            ptype.SetValue(typeof(string), 0);
            switch (TabMisc)
            {
                case PageTabMisc.Detail:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryDetail," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.CateGory:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryCateGory," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.Monthly:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryMonthly," + "WP.IM.Form", true, true);
                    break;
                case PageTabMisc.Yearly:
                    typeObj = Type.GetType("WP.IM.Form.frmImSlsHistQryYear," + "WP.IM.Form", true, true);
                    break;
            }
            if (typeObj != null)
            {
                foreach (Control con in conTabPage.Controls)
                {
                    if (con.Name == "frmImSlsHistQryDetail" || con.Name == "frmImSlsHistQryCateGory" ||
                        con.Name == "frmImSlsHistQryMonthly" || con.Name == "frmImSlsHistQryYear")
                    {
                        System.Reflection.MethodInfo mInfo = con.GetType().GetMethod("QrySlsHistQryByCust", ptype);
                        object[] Param = { strCustNo };
                        if (mInfo != null)
                        {
                            mInfo.Invoke(con, Param);
                        }
                    }
                }
            }
        }

        public static void frmImSlsHistByItemQry_ShowForm()
        {
            object obj = null;
            Type[] ptype = new Type[0];

            Type typeObj = Type.GetType("WP.IM.Form.frmImSlsHistByItemQry," + "WP.IM.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm", ptype);
                object[] Param = new object[0];
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmImSlsHistByCustQry_ShowForm()
        {
            object obj = null;
            Type[] ptype = new Type[0];

            Type typeObj = Type.GetType("WP.IM.Form.frmImSlsHistByCustQry," + "WP.IM.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm", ptype);
                object[] Param = new object[0];
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmImSlsHistBySlspQry_ShowForm()
        {
            object obj = null;
            Type[] ptype = new Type[0];

            Type typeObj = Type.GetType("WP.IM.Form.frmImSlsHistBySlspQry," + "WP.IM.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm", ptype);
                object[] Param = new object[0];
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        #endregion

        #region MF
        public static void frmMNameDictMtn_ShowForm()
        {
            object obj = null;
            //Type[] ptype = new Type[1];
            //ptype.SetValue(typeof(int), 0);
            Type typeObj = Type.GetType("WP.MF.Form.frmMNameDictMtn," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm");
                object[] Param = null;
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void frmMUserMenuMtn_ShowForm()
        {
            object obj = null;
            Type typeObj = Type.GetType("WP.MF.Form.frmMUserMenuMtn," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm");
                object[] Param = null;
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmMWindowDictMtn_ShowForm()
        {
            object obj = null;
            Type typeObj = Type.GetType("WP.MF.Form.frmMWindowDictMtn," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm");
                object[] Param = null;
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmMMenuDictMtn_ShowForm()
        {
            object obj = null;
            Type typeObj = Type.GetType("WP.MF.Form.frmMMenuDictMtn," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm");
                object[] Param = null;
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmMMessageDictMtn_ShowForm()
        {
            object obj = null;
            Type typeObj = Type.GetType("WP.MF.Form.frmMMessageDictMtn," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm");
                object[] Param = null;
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmMFieldsDictMtn_ShowForm()
        {
            object obj = null;
            Type typeObj = Type.GetType("WP.MF.Form.frmMFieldsDictMtn," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowForm");
                object[] Param = null;
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        public static void frmMSchedulerMtn_ShowForm(string strUserName, string strFromDate, string strToDate, string strFromTime, string strToTime, bool bIsAllDay, FormStatus fsStatus, SchedulerType stType)
        {
            Type[] ptype = new Type[8];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(bool), 5);
            ptype.SetValue(typeof(FormStatus), 6);
            ptype.SetValue(typeof(SchedulerType), 7);

            Type typeObj = Type.GetType("WP.MF.Form.frmMScheduleMtn," + "WP.MF.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj, null);
                System.Reflection.MethodInfo mInfo1 = oPurge.GetType().GetMethod("ShowForm", ptype);
                object[] Param1 = { strUserName, strFromDate, strToDate, strFromTime, strToTime, bIsAllDay, fsStatus, stType };
                if (mInfo1 != null)
                {
                    mInfo1.Invoke(oPurge, Param1);
                }
            }
        }


        #endregion

        #region PO
        /// <summary>
        /// call frmPoHistQry
        /// </summary>
        /// <param name="intQueryType">intQueryType 0----ByOrdNo
        ///                            intQueryType 1----BySupNo
        /// </param>
        /// <param name="strOrdNoOrSupNo"> OrdNoOrSupNo </param>
        public static void frmPoHistQry_ShowFrom(int intQueryType, string strOrdNoOrSupNo)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(int), 0);
            ptype.SetValue(typeof(string), 1);

            Type typeObj = Type.GetType("WP.PO.Form.frmPoHistQry," + "WP.PO.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("ShowFrom", ptype);
                object[] Param = { intQueryType, strOrdNoOrSupNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }
        #endregion

        /// <summary>
        /// provide a search item function like google search
        /// </summary>
        /// <param name="strFindValue"></param>
        /// <param name="blnByDescription"></param>
        /// <returns></returns>
        public static DataView GetItemForSearch(string strFindValue, bool blnByDescription)
        {
            return GetItemForSearch(strFindValue, blnByDescription, "");
        }

        public static DataView GetItemForSearch(string strFindValue, bool blnByDescription, string strCondition)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(bool), 1);
            ptype.SetValue(typeof(string), 2);

            Type typeObj = Type.GetType("WP.IM.DataAccess.ImInvMasterDAL," + "WP.IM.DataAccess", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("GetItemForSearch", ptype);
                object[] Param = { strFindValue, blnByDescription, strCondition };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oPurge, Param);
                }
            }
            if (obj != null)
                return obj as DataView;
            else
                return null;
        }

        public static string GetItemForSearchCondition(string strFindValue, bool blnByDescription, string strCondition)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(bool), 1);
            ptype.SetValue(typeof(string), 2);

            Type typeObj = Type.GetType("WP.IM.DataAccess.ImInvMasterDAL," + "WP.IM.DataAccess", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("GetItemForSearchCondition", ptype);
                object[] Param = { strFindValue, blnByDescription, strCondition };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oPurge, Param);
                }
            }
            if (obj != null)
                return obj as string;
            else
                return "";
        }

        public static DataView GetCustForSearch(string strFindValue, bool blnByDescription)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(bool), 1);

            Type typeObj = Type.GetType("WP.AR.DataAccess.ArCustomerDAL," + "WP.AR.DataAccess", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("GetCustForSearch", ptype);
                object[] Param = { strFindValue, blnByDescription };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oPurge, Param);
                }
            }
            if (obj != null)
                return obj as DataView;
            else
                return null;
        }
        public static DataView GetSupForSearch(string strFindValue, bool blnByDescription)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(bool), 1);

            Type typeObj = Type.GetType("WP.AP.DataAccess.ApSupplierDAL," + "WP.AP.DataAccess", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("GetSupForSearch", ptype);
                object[] Param = { strFindValue, blnByDescription };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oPurge, Param);
                }
            }
            if (obj != null)
                return obj as DataView;
            else
                return null;
        }
        public static void frmMainMenu_RefreshMenu()
        {
            Type oType = Type.GetType("Maxleaf.frmMainMenu," + "Maxleaf", true, true);
            if (oType != null)
            {
                System.Reflection.MethodInfo mInfo = SysVar.MDIParentForm.GetType().GetMethod("RefreshMenu");
                if (mInfo != null) mInfo.Invoke(SysVar.MDIParentForm, null);
            }
        }

        public static void frmMainMenu_ShowUserAlert()
        {
            Type oType = Type.GetType("Maxleaf.frmMainMenu," + "Maxleaf", true, true);
            if (oType != null)
            {
                System.Reflection.MethodInfo mInfo = SysVar.MDIParentForm.GetType().GetMethod("ShowUserAlert");
                if (mInfo != null) mInfo.Invoke(SysVar.MDIParentForm, null);
            }
        }

        public static void frmImRecommendSplitLot_ShowMe(string strMenuName, string strLotNo, bool blnShowOrigLot)
        {
            object obj = null;

            Type type = Type.GetType("WP.IM.Form.frmImRecommendSplitLot," + "WP.IM.Form", true, true);
            if (type != null)
            {
                object ofrm = System.Activator.CreateInstance(type);

                MenuInfo menuinfo = new MenuInfo();
                menuinfo.strMenuName = strMenuName;
                PropertyInfo pInfo = ofrm.GetType().GetProperty("CurrentMenuInfo");
                if (pInfo != null)
                {
                    pInfo.SetValue(ofrm, menuinfo, null);
                }

                Type[] ptype = new Type[2];
                ptype.SetValue(typeof(string), 0);
                ptype.SetValue(typeof(bool), 1);

                System.Reflection.MethodInfo mInfo = ofrm.GetType().GetMethod("ShowMe", ptype);
                object[] Param = { strLotNo, blnShowOrigLot };
                if (mInfo != null)
                {
                    mInfo.Invoke(ofrm, Param);
                }
            }
        }
        public static void frmImSplitLotByPK_ShowMe(string strMenuName, string strLotNo)
        {
            object obj = null;

            Type type = Type.GetType("WP.IM.Form.frmImSplitLotByPK," + "WP.IM.Form", true, true);
            if (type != null)
            {
                object ofrm = System.Activator.CreateInstance(type);

                MenuInfo menuinfo = new MenuInfo();
                menuinfo.strMenuName = strMenuName;
                PropertyInfo pInfo = ofrm.GetType().GetProperty("CurrentMenuInfo");
                if (pInfo != null)
                {
                    pInfo.SetValue(ofrm, menuinfo, null);
                }

                Type[] ptype = new Type[1];
                ptype.SetValue(typeof(string), 0);


                System.Reflection.MethodInfo mInfo = ofrm.GetType().GetMethod("ShowMe", ptype);
                object[] Param = { strLotNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(ofrm, Param);
                }
            }
        }
        public static void frmImLotAdjust_AdjLot(string strMenuName, string strLotNo, bool blnPromptInvalidLotNo, bool blnNeedShowWindow)
        {
            object obj = null;

            Type type = Type.GetType("WP.IM.Form.frmImLotAdjust," + "WP.IM.Form", true, true);
            if (type != null)
            {
                object ofrm = System.Activator.CreateInstance(type);

                MenuInfo menuinfo = new MenuInfo();
                menuinfo.strMenuName = strMenuName;
                PropertyInfo pInfo = ofrm.GetType().GetProperty("CurrentMenuInfo");
                if (pInfo != null)
                {
                    pInfo.SetValue(ofrm, menuinfo, null);
                }


                Type[] ptype = new Type[3];
                ptype.SetValue(typeof(string), 0);
                ptype.SetValue(typeof(bool), 1);
                ptype.SetValue(typeof(bool), 2);

                System.Reflection.MethodInfo mInfo = ofrm.GetType().GetMethod("AdjLot", ptype);
                object[] Param = { strLotNo, blnPromptInvalidLotNo, blnNeedShowWindow };
                if (mInfo != null)
                {
                    mInfo.Invoke(ofrm, Param);
                }
            }
        }
        public static void frmImTagAdjust_AdjTag(string strMenuName, string strTagNo)
        {
            object obj = null;


            Type type = Type.GetType("WP.IM.Form.frmImTagAdjust," + "WP.IM.Form", true, true);
            if (type != null)
            {
                object ofrm = System.Activator.CreateInstance(type);

                MenuInfo menuinfo = new MenuInfo();
                menuinfo.strMenuName = strMenuName;
                PropertyInfo pInfo = ofrm.GetType().GetProperty("CurrentMenuInfo");
                if (pInfo != null)
                {
                    pInfo.SetValue(ofrm, menuinfo, null);
                }

                Type[] ptype = new Type[1];
                ptype.SetValue(typeof(string), 0);

                System.Reflection.MethodInfo mInfo = ofrm.GetType().GetMethod("AdjTag", ptype);
                object[] Param = { strTagNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(ofrm, Param);
                }
            }

        }

        public static bool frmOeTallyCalculator_ShowFromRM(TallyCalculatorType type, string strItemNo, string strLocNo, string strOrderUnit, string strShipUnit, string strOldTally, ref string strNewTally, ref double dblNewQtyOrder,
                      ref double dblNewShipQty, ref bool bAlreadyGenTally, int iOeDetailRecID, string strOrdNo)
        {
            object obj = null;
            object blnReturn = null;
            Type[] ptype = new Type[12];
            ptype.SetValue(typeof(TallyCalculatorType), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);
            ptype.SetValue(typeof(string), 4);
            ptype.SetValue(typeof(string), 5);
            ptype.SetValue(typeof(string), 6);
            ptype.SetValue(typeof(double), 7);
            ptype.SetValue(typeof(double), 8);
            ptype.SetValue(typeof(bool), 9);
            ptype.SetValue(typeof(int), 10);
            ptype.SetValue(typeof(string), 11);

            Type typeObj = Type.GetType("WP.OE.Form.frmOeTallyCalculator," + "WP.OE.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);
                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("CalcTallyFromRM", ptype);


                System.Reflection.MethodInfo[] mInfos = oPurge.GetType().GetMethods();

                foreach (System.Reflection.MethodInfo info in mInfos)
                {

                    if (info.Name == "CalcTallyFromRM")
                    {
                        if (info.GetParameters().Length == 12)
                        {
                            object[] Param = new object[] { type, strItemNo, strLocNo, strOrderUnit, strShipUnit, strOldTally, strNewTally, dblNewQtyOrder, dblNewShipQty, bAlreadyGenTally, iOeDetailRecID, strOrdNo };

                            if (info != null)
                            {
                                blnReturn = info.Invoke(oPurge, Param);
                                if (CvtFunc.ToBoolean(blnReturn))
                                {
                                    strNewTally = CvtFunc.ToString(Param[6]);
                                    dblNewQtyOrder = CvtFunc.ToDouble(Param[7]);
                                    dblNewShipQty = CvtFunc.ToDouble(Param[8]);
                                    bAlreadyGenTally = CvtFunc.ToBoolean(Param[9]);
                                }
                            }
                        }
                    }
                }
                return CvtFunc.ToBoolean(blnReturn);
            }
            return false;
        }

        public static void frmImInvAvlTrfTagMtn_ItemTagTransfer(string strMenuName, string strItemNo, string strLocNo)
        {
            object obj = null;

            Type type = Type.GetType("WP.IM.Form.frmImInvAvlTrfTagMtn," + "WP.IM.Form", true, true);
            if (type != null)
            {
                object ofrm = System.Activator.CreateInstance(type);

                MenuInfo menuinfo = new MenuInfo();
                menuinfo.strMenuName = strMenuName;
                PropertyInfo pInfo = ofrm.GetType().GetProperty("CurrentMenuInfo");
                if (pInfo != null)
                {
                    pInfo.SetValue(ofrm, menuinfo, null);
                }

                Type[] ptype = new Type[2];
                ptype.SetValue(typeof(string), 0);
                ptype.SetValue(typeof(string), 1);

                System.Reflection.MethodInfo mInfo = ofrm.GetType().GetMethod("ItemTagTransfer", ptype);
                object[] Param = { strItemNo, strLocNo };
                if (mInfo != null)
                {
                    mInfo.Invoke(ofrm, Param);
                }
            }

        }


        public static void frmPoRecommentList_RecomPo()
        {
            object obj = null;
            Type[] ptype = new Type[0];

            Type typeObj = Type.GetType("WP.PO.Form.frmPoRecommentList," + "WP.PO.Form", true, true);
            if (typeObj != null)
            {
                object oPurge = System.Activator.CreateInstance(typeObj);

                System.Reflection.MethodInfo mInfo = oPurge.GetType().GetMethod("RecomPo", ptype);
                object[] Param = new object[0];
                if (mInfo != null)
                {
                    mInfo.Invoke(oPurge, Param);
                }
            }
        }

        public static void UpdateShipdate(DBAccess dBAccess, string strOrdNo, DateTime datShipdate)
        {

            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(WP.DB.DBAccess), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(DateTime), 2);

            string strNamedSpace = "WP.OE.DataAccess";

            Type typeOeOrderHdrDAL = Type.GetType(strNamedSpace + ".OeOrderHdrDAL," + strNamedSpace, true, true);
            if (typeOeOrderHdrDAL != null)
            {
                object oDal = System.Activator.CreateInstance(typeOeOrderHdrDAL);

                System.Reflection.MethodInfo mInfo = oDal.GetType().GetMethod("UpdateShipdate", ptype);
                object[] Param = { dBAccess, strOrdNo, datShipdate };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oDal, Param);
                }
            }
        }



        public static bool UpdateNewTagNo_ImTrf(string strDocNo, int iSeqNo, int iTallySeqNo, string strNewTagNo)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(string), 3);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "UpdateNewTagNo";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo, strNewTagNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }
        public static bool UpdateNewLotNo_ImTrf(string strDocNo, int iSeqNo, int iTallySeqNo, string strNewLotNo)
        {

            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(int), 1);
            ptype.SetValue(typeof(int), 2);
            ptype.SetValue(typeof(string), 3);

            string strNamedSpace = "WP.IM.BusinessLogical";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".ImTrfHdrBLL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "UpdateNewLotNo";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { strDocNo, iSeqNo, iTallySeqNo, strNewLotNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;

        }

        public static void ReCreatePoGoodsRecvJournal(DBAccess dbcon, PrintInfo printInfo, int intJnlNo)
        {
            //PoGoodsRecvEditList(DBAccess dbcon, PrintInfo printInfo, bool DisplayCost, bool IsPrintJournal, bool blnShowModal,int intReCreateJournalNo)
            object obj = null;
            Type[] ptype = new Type[6];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(PrintInfo), 1);
            ptype.SetValue(typeof(bool), 2);
            ptype.SetValue(typeof(bool), 3);
            ptype.SetValue(typeof(bool), 4);
            ptype.SetValue(typeof(int), 5);

            string strNamedSpace = "WP.PO.Report";
            Type type = Type.GetType(strNamedSpace + ".Print," + strNamedSpace, true, true);
            if (type != null)
            {
                object oRpt = System.Activator.CreateInstance(type);
                string strMethod = "PoGoodsRecvEditList";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dbcon, printInfo, true, true, true, intJnlNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);

                }
            }
        }

        public static void ReCreateOeInvoiceJournal(DBAccess dbcon, PrintInfo printInfo, int intJnlNo)
        {
            //OeInvoiceEditList(DBAccess dbcon, PrintInfo printInfo, bool PageBreak, bool IsPrintJournal, bool blnShowModal,int intReCreateJournalNo)
            #region OeInvoiceEditList
            Type OeInvoiceEditListType = ReflectMethod.GetReportType(SystemModules.OE, "OeInvoiceEditList");
            if (OeInvoiceEditListType != null)
            {
                Type[] ptype = new Type[6];
                ptype.SetValue(typeof(DBAccess), 0);
                ptype.SetValue(typeof(PrintInfo), 1);
                ptype.SetValue(typeof(Boolean), 2);
                ptype.SetValue(typeof(Boolean), 3);
                ptype.SetValue(typeof(Boolean), 4);
                ptype.SetValue(typeof(int), 5);
                object[] Param = { dbcon, printInfo, DataFunctions.GetmSwitchValue(dbcon, "PgBrkOnEditList", "OE"), true, true, intJnlNo };
                object oRpt = System.Activator.CreateInstance(OeInvoiceEditListType);
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod("OeInvoiceEditList", ptype);
                if (mInfo != null) mInfo.Invoke(oRpt, Param);
            }
            #endregion


        }
        public static void TagInspection(TallyInModuleType moduleType, string strItemNo, string strLocNo, string strTagNo)
        {
            object obj = null;
            Type[] ptype = new Type[4];
            ptype.SetValue(typeof(TallyInModuleType), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(string), 2);
            ptype.SetValue(typeof(string), 3);

            string strNamedSpace = "WP.IM.Form";
            Type type = Type.GetType(strNamedSpace + ".frmimInvTagInspectionPartialMtn," + strNamedSpace, true, true);
            if (type != null)
            {
                object oRpt = System.Activator.CreateInstance(type);

                PropertyInfo prop = oRpt.GetType().GetProperty("CurrentMenuInfo");
                MenuInfo menu = new MenuInfo();
                menu.strMenuId = SysVar.CurrentMenuInfo.strMenuId;
                menu.strMenuName = "Inspection Maintenance";
                menu.strNameSpace = "WP.IM.Form";
                menu.strPermit = "Y";
                menu.strOverViewCondition = string.Empty;
                menu.strProgname = string.Empty;
                menu.strTableName = string.Empty;

                prop.SetValue(oRpt, menu, null);

                string strMethod = "ShowForm";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { moduleType, strItemNo, strLocNo, strTagNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);

                }
            }
        }
        public static void PrintExtraCostRpt(DBAccess dbcon, PrintInfo printInfo, ExtrCostType etExtrCostType)
        {
            object obj = null;
            string strModule = string.Empty;
            string strMethodName = string.Empty;
            Type[] ptype = new Type[2];
            ptype.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
            ptype.SetValue(Type.GetType("WP.Commons.PrintInfo," + "WP.Commons", true, true), 1);

            switch (etExtrCostType)
            {
                case ExtrCostType.POPurchase:
                    strModule = "PO";
                    strMethodName = "";
                    break;
                case ExtrCostType.POGoodsRecv:
                    strModule = "PO";
                    strMethodName = "PoGoodsRecvAdditionalLandedCostRpt";
                    break;
                case ExtrCostType.OESalesOrder:
                    strModule = "OE";
                    strMethodName = "OeExtraCostRpt";
                    break;
                case ExtrCostType.OEReturn:
                    strModule = "OE";
                    break;
                case ExtrCostType.OEQuote:
                    strModule = "OE";
                    break;
                case ExtrCostType.Reman:
                    strModule = "RM";
                    break;
                case ExtrCostType.Transfer:
                    strModule = "IM";
                    break;
            }

            string strNamedSpace = "WP." + strModule + ".Report";
            Type typeRpt = Type.GetType(strNamedSpace + ".Print," + strNamedSpace, true, true);
            if (typeRpt != null)
            {
                object oRpt = Activator.CreateInstance(typeRpt);
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethodName, ptype);

                object[] Param ={ dbcon, printInfo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                }
            }
        }

        public static void PrintExtraCostRpt_ToExcel(DBAccess dbcon, PrintInfo printInfo, ExtrCostType etExtrCostType)
        {
            object obj = null;
            string strModule = string.Empty;
            string strMethodName = string.Empty;
            Type[] ptype = new Type[2];
            ptype.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
            ptype.SetValue(Type.GetType("WP.Commons.PrintInfo," + "WP.Commons", true, true), 1);

            switch (etExtrCostType)
            {
                case ExtrCostType.POPurchase:
                    strModule = "PO";
                    strMethodName = "";
                    break;
                case ExtrCostType.POGoodsRecv:
                    strModule = "PO";
                    strMethodName = "PoGoodsRecvAdditionalLandedCostRpt_ToExcel";
                    break;
                case ExtrCostType.OESalesOrder:
                    strModule = "OE";
                    strMethodName = "OeExtraCostRpt_ToExcel";
                    break;
                case ExtrCostType.OEReturn:
                    strModule = "OE";
                    break;
                case ExtrCostType.OEQuote:
                    strModule = "OE";
                    break;
                case ExtrCostType.Reman:
                    strModule = "RM";
                    break;
                case ExtrCostType.Transfer:
                    strModule = "IM";
                    break;
            }

            string strNamedSpace = "WP." + strModule + ".Report";
            Type typeRpt = Type.GetType(strNamedSpace + ".Print," + strNamedSpace, true, true);
            if (typeRpt != null)
            {
                object oRpt = Activator.CreateInstance(typeRpt);
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethodName, ptype);

                object[] Param ={ dbcon, printInfo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                }
            }
        }

        public static bool ConfirmOEShipped(DBAccess dbcon, string[] strInvNos)
        {
            object obj = null;
            Type[] ptype = new Type[2];
            ptype.SetValue(typeof(DBAccess), 0);
            ptype.SetValue(typeof(string[]), 1);
            string strNamedSpace = "WP.OE.DataAccess";
            Type typePoOrderHdrBLL = Type.GetType(strNamedSpace + ".OeOrderHdrDAL," + strNamedSpace, true, true);
            if (typePoOrderHdrBLL != null)
            {
                object oRpt = System.Activator.CreateInstance(typePoOrderHdrBLL);
                string strMethod = "ConfirmShipped";
                System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod(strMethod, ptype);
                object[] Param = { dbcon, strInvNos };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oRpt, Param);
                    return bool.Parse(obj.ToString());
                }
            }
            return false;
        }

        public static void ShowLog(string strSys, string strOrdNo, int intSeqNo)
        {
            object obj = null;
            Type[] ptype = new Type[3];
            ptype.SetValue(typeof(string), 0);
            ptype.SetValue(typeof(string), 1);
            ptype.SetValue(typeof(int), 2);

            Type typeFrm = Type.GetType("WP.MF.Form.frmMLogQry," + "WP.MF.Form", true, true);
            if (typeFrm != null)
            {
                object oQry = System.Activator.CreateInstance(typeFrm);

                System.Reflection.MethodInfo mInfo = oQry.GetType().GetMethod("ShowLog", ptype);
                object[] Param = { strSys, strOrdNo, intSeqNo };
                if (mInfo != null)
                {
                    obj = mInfo.Invoke(oQry, Param);
                }
            }
        }
    }

    #endregion

    #region Mouse Click
    public class SimulateMouse
    {
        struct NativeRECT
        {
            public int left;
            public int top;
            public int right;
            public int bottom;
        }

        [Flags]
        enum MouseEventFlag : uint
        {
            Move = 0x0001,
            LeftDown = 0x0002,
            LeftUp = 0x0004,
            RightDown = 0x0008,
            RightUp = 0x0010,
            MiddleDown = 0x0020,
            MiddleUp = 0x0040,
            XDown = 0x0080,
            XUp = 0x0100,
            Wheel = 0x0800,
            VirtualDesk = 0x4000,
            Absolute = 0x8000
        }

        public struct POINTAPI
        {
            public Int32 x;
            public Int32 y;
        }

        [DllImport("user32.dll")]
        static extern bool SetCursorPos(int X, int Y);

        [DllImport("user32.dll")]
        static extern Int32 GetCursorPos(out POINTAPI lpPoint);

        [DllImport("user32.dll")]
        static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);

        [DllImport("user32.dll")]
        static extern IntPtr FindWindow(string strClass, string strWindow);

        [DllImport("user32.dll")]
        static extern IntPtr FindWindowEx(HandleRef hwndParent, HandleRef hwndChildAfter, string strClass, string strWindow);

        [DllImport("user32.dll")]
        static extern bool GetWindowRect(HandleRef hwnd, out NativeRECT rect);


        public static void MouseClickForm(Form frm)
        {
            POINTAPI lPos = new POINTAPI();
            GetCursorPos(out lPos);

            Point endPosition = new Point(frm.Left, frm.Top);
            NativeRECT rect;
            GetWindowRect(new HandleRef(frm, frm.Handle), out rect);
            endPosition.X = (rect.left + rect.right) / 2 - frm.Width / 2;
            endPosition.Y = (rect.top + rect.bottom) / 2;
            SetCursorPos(endPosition.X, endPosition.Y);
            mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, UIntPtr.Zero);
            mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, UIntPtr.Zero);

            //  SetCursorPos(lPos.x, lPos.y);
        }
    }
    #endregion

    #region Docuxplorer
    public class Docuxplorer
    {
        public enum OperationType
        { AddFile = 0, FindFile, PrintFile };
        public enum DocType
        { SalesOrder = 0, OeReturn, GoodsRecv, PoReturn, MiscSupAP, AccruPayable, PrintInvoice, RM, ARCust };
        public enum DocXPPrintType
        { Invoice = 0, SalesGM, TPTrans, OeReturn, PrintInvoice }
        public bool AddDocXPDoc(DocType docType, DataRow drRow, string strFieldName)
        {
            return AddDocXPDoc(docType, drRow, strFieldName, "");
        }
        public bool AddDocXPDoc(DocType docType, DataRow drRow, string strFieldName, string strGRN)
        {
            string strPath = Application.StartupPath;
            if (File.Exists(strPath + "\\Import.dx")) File.Delete(strPath + "\\Import.dx");
            try
            {
                switch (docType)
                {
                    case DocType.SalesOrder:
                        AddDocXPSalesOrder(drRow, strFieldName);
                        break;
                    case DocType.GoodsRecv:
                        AddDocXPGoodsRecv(drRow, strGRN, strFieldName);
                        break;
                    case DocType.MiscSupAP:
                        AddDocXPMiscSupInv(drRow, strFieldName);
                        break;
                    case DocType.AccruPayable:
                        AddDocXPAccruPayable(drRow, strFieldName);
                        break;
                    case DocType.OeReturn:
                        AddDocXPOeReturn(drRow, strFieldName);
                        break;
                    case DocType.PrintInvoice:
                        AddDocXPPrintInvoice(drRow, strFieldName);
                        break;
                    case DocType.RM:
                        AddDocXPRM(drRow, strFieldName);
                        break;
                    case DocType.ARCust:
                        AddDocXPARCust(drRow, strFieldName);
                        break;
                }
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
        }

        public bool FindDocXPFile(DocType docType, DataRow drRow, string strGRN, string strNewInvNo)
        {
            string strPath = Application.StartupPath;
            if (File.Exists(strPath + "\\Find.dx")) File.Delete(strPath + "\\Find.dx");
            try
            {
                switch (docType)
                {
                    case DocType.SalesOrder:
                        FindDocXPSalesOrder(drRow, strNewInvNo);
                        break;
                    case DocType.OeReturn:
                        FindDocXPOeReturn(drRow, strNewInvNo);
                        break;
                    case DocType.GoodsRecv:
                        FindDocXPGoodsRecv(drRow, strNewInvNo, strGRN);
                        break;
                    case DocType.MiscSupAP:
                        FindDocXPMiscSupInv(drRow, strNewInvNo);
                        break;
                    case DocType.AccruPayable:
                        FindDocXPAccruPayable(drRow, strNewInvNo);
                        break;
                    case DocType.PoReturn:
                        FindDocXPOeReturn(drRow, strNewInvNo);
                        break;
                    case DocType.RM:
                        FindDocXPRM(drRow, strNewInvNo);
                        break;
                    case DocType.ARCust:
                        FindDocXPARCust(drRow, strNewInvNo);
                        break;
                }
                System.Threading.Thread.Sleep(5000);
                //if (File.Exists(strPath + "\\Find.dx")) File.Delete(strPath + "\\Find.dx");                
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
        }
        #region Sales Order
        public bool AddDocXPSalesOrder(DataRow drRow, string strFieldName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.SalesOrder, OperationType.AddFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPSalesOrder(drRow, strFieldName);
            return Customize.DocXP.Demo.AddDocXPSalesOrder(drRow, strFieldName);
            return true;
        }
        public bool AddDocXPPrintInvoice(DataRow drRow, string strFileName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.PrintInvoice, OperationType.PrintFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPPrintInvoice(drRow, strFileName);
            return Customize.DocXP.Demo.AddDocXPPrintInvoice(drRow, strFileName);
            return true;
        }
        public bool FindDocXPSalesOrder(DataRow drRow, string strInvNo)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.SalesOrder, OperationType.FindFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPSalesOrder(drRow, strInvNo);
            return Customize.DocXP.Demo.FindDocXPSalesOrder(drRow, strInvNo);
            return true;
        }
        #endregion
        #region oeReturn
        public bool AddDocXPOeReturn(DataRow drRow, string strFieldName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.OeReturn, OperationType.AddFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPOeReturn(drRow, strFieldName);
            return Customize.DocXP.Demo.AddDocXPOeReturn(drRow, strFieldName);
            return true;
        }

        public bool FindDocXPOeReturn(DataRow drRow, string strInvNo)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.SalesOrder, OperationType.FindFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPOeReturn(drRow, strInvNo);
            return Customize.DocXP.Demo.FindDocXPOeReturn(drRow, strInvNo);
            return true;
        }
        #endregion
        #region GoodsRecv
        public bool AddDocXPGoodsRecv(DataRow drRow, string strGRN, string strFieldName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.GoodsRecv, OperationType.AddFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPGoodsRecv(drRow, strGRN, strFieldName);
            return Customize.DocXP.Demo.AddDocXPGoodsRecv(drRow, strGRN, strFieldName);
            return true;
        }

        public bool FindDocXPGoodsRecv(DataRow drRow, string strInvNo, string strGRN)
        {
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPGoodsRecv(drRow, strInvNo, strGRN);
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.GoodsRecv, OperationType.FindFile);
            return Customize.DocXP.Demo.FindDocXPGoodsRecv(drRow, strInvNo, strGRN);
            return true;
        }
        #endregion
        #region PoReturn
        public bool FindDocXPPoReturn(DocType docType, DataRow drRow, string strGRN, string strNewInvNo)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.PoReturn, OperationType.FindFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPPoReturn(drRow, strNewInvNo, strGRN);
            return Customize.DocXP.Demo.FindDocXPPoReturn(drRow, strNewInvNo, strGRN);
            return true;
        }
        #endregion
        #region MiscSupInv

        public bool AddDocXPMiscSupInv(DataRow drRow, string strFieldName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.MiscSupAP, OperationType.AddFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPMiscSupInv(drRow, strFieldName);
            return Customize.DocXP.Demo.AddDocXPMiscSupInv(drRow, strFieldName);
            return true;
        }

        public bool FindDocXPMiscSupInv(DataRow drRow, string strNewInvNo)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.MiscSupAP, OperationType.FindFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPMiscSupInv(drRow, strNewInvNo);
            return Customize.DocXP.Demo.FindDocXPMiscSupInv(drRow, strNewInvNo);
            return true;
        }
        #endregion
        #region AccruPayable
        public bool AddDocXPAccruPayable(DataRow drRow, string strFieldName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.AccruPayable, OperationType.AddFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPAccruPay(drRow, strFieldName);
            return Customize.DocXP.Demo.AddDocXPAccruPay(drRow, strFieldName);
            return true;
        }

        public bool FindDocXPAccruPayable(DataRow drRow, string strInvNo)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.AccruPayable, OperationType.FindFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPAccruPayable(drRow, strInvNo);
            return Customize.DocXP.Demo.FindDocXPAccruPayable(drRow, strInvNo);
            return true;
        }
        #endregion

        #region RM
        public bool AddDocXPRM(DataRow drRow, string strFieldName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.RM, OperationType.AddFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPAccruPay(drRow, strFieldName);
            return Customize.DocXP.Demo.AddDocXPRM(drRow, strFieldName);
            return true;
        }

        public bool FindDocXPRM(DataRow drRow, string strInvNo)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.RM, OperationType.FindFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPAccruPayable(drRow, strInvNo);
            return Customize.DocXP.Demo.FindDocXPRM(drRow, strInvNo);
            return true;
        }
        #endregion

        #region ARCUST
        public bool AddDocXPARCust(DataRow drRow, string strFieldName)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Import.dx", DocType.ARCust, OperationType.AddFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.AddDocXPAccruPay(drRow, strFieldName);
            return Customize.DocXP.Demo.AddDocXPARCUST(drRow, strFieldName);
            return true;
        }

        public bool FindDocXPARCust(DataRow drRow, string strInvNo)
        {
            string strPath = Application.StartupPath;
            CreateDocuXPFile(strPath + "\\Find.dx", DocType.ARCust, OperationType.FindFile);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro()) return Customize.DocXP.Demo.FindDocXPAccruPayable(drRow, strInvNo);
            return Customize.DocXP.Demo.FindDocXPARCUST(drRow, strInvNo);
            return true;
        }

        #endregion

        public void PrintDocXPFile(DocType docType, DataRow drRow, DocXPPrintType printType)
        {
            // intPrintType
            //0 -- invoice
            //1 -- GM
            //2 -- TP
            //
            string strPath = Application.StartupPath;
            DBAccess dbcon = new DBAccess(false, false);
            string strPageTitle = "";
            string strReportTitle = "";
            string strPrintName = "";
            string strFieldName = "";

            PrintInfo printInfo = new PrintInfo();
            strPrintName = "ActiveFax";
            printInfo.PrinterName = "";
            printInfo.PrintType = PrintInfo.OutputType.PDF;
            printInfo.Landscape = false;
            //printInfo.ReportPageTitle = strPageTitle;
            //printInfo.ReportTitle = strReportTitle;
            if (printType == DocXPPrintType.OeReturn)
            {
                printInfo.PrintCondition = "ReturnNo='" + drRow["ReturnNo"].ToString() + "'";
                strFieldName = strPath + "\\" + drRow["ReturnNo"].ToString().Trim(); ;
            }
            else
            {
                if (printType != DocXPPrintType.TPTrans)
                {
                    printInfo.PrintCondition = "OrdNo='" + drRow["OrdNo"].ToString() + "'";
                    strFieldName = strPath + "\\" + drRow["OrdNo"].ToString().Trim();
                }
                else
                {
                    printInfo.PrintCondition = " Type='O' and DocNo='" + drRow["DocNo"].ToString() + "'";
                    strFieldName = strPath + "\\" + drRow["DocNo"].ToString().Trim();
                }
            }
            printInfo.ReportExportType = PrintInfo.ExportType.PDF;
            printInfo.ReportExportFileName = strFieldName;
            if (printType == DocXPPrintType.Invoice) // Invoice
            {
                object obj = null;
                Type[] ptype = new Type[3];
                ptype.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
                ptype.SetValue(typeof(Boolean), 1);
                ptype.SetValue(Type.GetType("WP.Commons.PrintInfo," + "WP.Commons", true, true), 2);
                Type typeCustomizeRpt = CustomizeReportType.CurrentType();
                if (typeCustomizeRpt != null)
                {
                    object oRpt = System.Activator.CreateInstance(typeCustomizeRpt);
                    System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod("SalesOrderForm", ptype);
                    object[] Param = { dbcon, true, printInfo };
                    if (mInfo != null)
                    {
                        obj = mInfo.Invoke(oRpt, Param);
                    }

                    strFieldName = strFieldName + ".pdf";
                    if (File.Exists(strFieldName) != true)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }

                    AddDocXPDoc(DocType.SalesOrder, drRow, strFieldName);

                }
            }
            else if (printType == DocXPPrintType.PrintInvoice)
            {
                object obj = null;
                Type[] ptype = new Type[4];
                ptype.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
                ptype.SetValue(typeof(Boolean), 1);
                ptype.SetValue(Type.GetType("WP.Commons.PrintInfo," + "WP.Commons", true, true), 2);
                ptype.SetValue(typeof(Boolean), 3);
                Type typeCustomizeRpt = CustomizeReportType.CurrentType();
                if (typeCustomizeRpt != null)
                {
                    object oRpt = System.Activator.CreateInstance(typeCustomizeRpt);
                    System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod("SalesOrderForm", ptype);
                    object[] Param = { dbcon, true, printInfo, false };
                    if (mInfo != null)
                    {
                        obj = mInfo.Invoke(oRpt, Param);
                    }
                    strFieldName = strFieldName + ".pdf";
                    System.Threading.Thread.Sleep(1000);
                    if (File.Exists(strFieldName) != true)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                    AddDocXPDoc(DocType.PrintInvoice, drRow, strFieldName);
                }

            }
            else if (printType == DocXPPrintType.SalesGM)
            {
                object obj = null;
                Type[] ptype = new Type[2];
                ptype.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
                ptype.SetValue(Type.GetType("WP.Commons.PrintInfo," + "WP.Commons", true, true), 1);
                Type typeCustomizeRpt = CustomizeReportType.CurrentType();
                if (typeCustomizeRpt != null)
                {
                    object oRpt = System.Activator.CreateInstance(typeCustomizeRpt);
                    System.Reflection.MethodInfo mInfo = oRpt.GetType().GetMethod("SalesGrossMarginSheet", ptype);
                    object[] Param = { dbcon, printInfo };
                    if (mInfo != null)
                    {
                        obj = mInfo.Invoke(oRpt, Param);
                    }

                    strFieldName = strFieldName + ".pdf";
                    if (File.Exists(strFieldName) != true)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }

                    if (File.Exists(strFieldName) == true)
                        AddDocXPDoc(DocType.SalesOrder, drRow, strFieldName);
                }
            }
            else if (printType == DocXPPrintType.TPTrans)
            {

                object obj = null;
                int intType = 0;
                Type[] ptype = null;
                Type typeCustomizeRpt = null;

                ptype = new Type[4];
                ptype.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
                ptype.SetValue(Type.GetType("WP.Commons.PrintInfo," + "WP.Commons", true, true), 1);
                ptype.SetValue(typeof(int), 2);
                ptype.SetValue(typeof(int), 3);
                typeCustomizeRpt = CustomizeReportType.CurrentType();
                if (typeCustomizeRpt != null)
                {
                    object oRpt = Activator.CreateInstance(typeCustomizeRpt);
                    MethodInfo mInfo = oRpt.GetType().GetMethod("TpTransportationForm_Notification", ptype);
                    object[] Param = { dbcon, printInfo, 0, intType };
                    if (mInfo != null)
                    {
                        obj = mInfo.Invoke(oRpt, Param);
                    }

                    string strSQL = "select * from oeorderhdr where invno='" + drRow["DocNo"].ToString() + "'";
                    drRow = dbcon.GetDataFirstRow(strSQL);
                    strFieldName = strFieldName + ".pdf";
                    if (File.Exists(strFieldName) != true)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                    if (File.Exists(strFieldName) == true)
                        AddDocXPDoc(DocType.SalesOrder, drRow, strFieldName);
                }
            }
            else if (printType == DocXPPrintType.OeReturn)
            {
                object obj = null;
                int intType = 0;
                Type[] ptype = new Type[2];
                ptype.SetValue(Type.GetType("WP.DB.DBAccess," + "WP.DB", true, true), 0);
                ptype.SetValue(Type.GetType("WP.Commons.PrintInfo," + "WP.Commons", true, true), 1);
                Type typeCustomizeRpt = CustomizeReportType.CurrentType();
                if (typeCustomizeRpt != null)
                {
                    object oRpt = Activator.CreateInstance(typeCustomizeRpt);
                    MethodInfo mInfo = oRpt.GetType().GetMethod("SalesReturnForm", ptype);
                    object[] Param = { dbcon, printInfo };
                    if (mInfo != null)
                    {
                        obj = mInfo.Invoke(oRpt, Param);
                    }
                    strFieldName = strFieldName + ".pdf";
                    if (File.Exists(strFieldName) != true)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                    if (File.Exists(strFieldName) == true)
                        AddDocXPDoc(DocType.OeReturn, drRow, strFieldName);
                }
            }
            if (docType != DocType.PrintInvoice)
            {
                //System.Threading.Thread.Sleep(5000);
                //if (File.Exists(strFieldName) == true) File.Delete(strFieldName);
            }
            Cursor.Current = Cursors.Default;
        }
        public void CreateDocuXPFile(string FileName, DocType docType, OperationType operType)
        {
            string strIni = "";
            StreamWriter writer = new StreamWriter(FileName, true);
            //if (SysVar.CodeSignNo == SysVar.DefineCompany.Demo || Customize.IsNuPro() || SysVar.CodeSignNo == SysVar.DefineCompany.BuildingPlus ) 
            strIni = Customize.DocXP.Demo.CreateIniString(docType, operType);
            writer.WriteLine(strIni);
            writer.Close();
        }

    }
    #endregion

    #region ToExcel
    public class ToExcel
    {       
        public static void DataGirdViewToExcel(DataView dv, DataGridView gdvGrid)
        {
            if (dv == null || gdvGrid == null || gdvGrid.Columns.Count == 0) return;

            TableRange cell = null;

            TableSheet page = TableSheet.CreateAvailable(null);

            TableRange data = page.Range(page.CurrentRow, 1, page.CurrentRow + dv.Count, gdvGrid.Columns.Count);
            data.CreateArray();
            string[] strColumnFormat = new string[gdvGrid.Columns.Count + 1];
            for (int i = 0; i < dv.Count; i++)
            {
                int x = 0;
                for (int j = 0; j < gdvGrid.Columns.Count; j++)
                {
                    if (gdvGrid.Columns[j].Visible)
                    {
                        x++;
                        if (i == 0)
                        {
                            data[i, x - 1] = gdvGrid.Columns[j].HeaderText;
                        }

                        //2009-01-19    Z    format column
                        if (strColumnFormat[x - 1] == null || strColumnFormat[x - 1].Length == 0)
                        {
                            if (dv.Table.Columns[j].DataType == typeof(string))
                            {
                                strColumnFormat[x - 1] = "@";

                                try
                                {
                                    if (!(strColumnFormat[x - 1] == null || strColumnFormat[x - 1].Length == 0))
                                    {


                                        cell = page.Columns(x);
                                        cell.NumberFormat = strColumnFormat[x - 1];
                                        if (strColumnFormat[x - 1].Equals("@"))
                                        {
                                            cell.HAlign = HAlign.Left;
                                        }

                                    }

                                }
                                catch (Exception ex)
                                {
                                    ExceptionManager.ProcessException(ex);
                                }
                            }
                            else if (dv.Table.Columns[j].DataType == typeof(decimal))
                            {
                                strColumnFormat[x - 1] = "#,##0";

                                try
                                {
                                    if (!(strColumnFormat[x - 1] == null || strColumnFormat[x - 1].Length == 0))
                                    {
                                        cell = page.Columns(x);
                                        cell.NumberFormat = strColumnFormat[x - 1];

                                        cell.HAlign = HAlign.Right;
                                    }

                                }
                                catch (Exception ex)
                                {
                                    ExceptionManager.ProcessException(ex);
                                }
                            }
                        }
                        data[i + 1, x - 1] = (dv[i][j] == DBNull.Value ? string.Empty : dv[i][j]);
                    }
                }
            }

            data.FlushArray();

            page.AutoFitColumns();
            page.Visible = true;
        }

        public static string GetColumnName(int iCol)
        {
            if (iCol <= 26)
            {
                return Convert.ToChar((int)'A' + iCol - 1).ToString();
            }
            else if (iCol % 26 == 0)
            {
                return (GetColumnName((iCol - 1) / 26) + "Z");
            }
            return (GetColumnName(iCol / 26) + GetColumnName(iCol % 26));
        }

        public static void DataGirdViewToExcel(DataView dv, WP.Controls.DataGridCom gdvGrid)
        {
            if (dv == null || gdvGrid == null || gdvGrid.Columns.Count == 0) return;

            Excel.Application xlApplication = new Excel.Application();
            Excel.Workbooks xlBooks = (Excel.Workbooks)xlApplication.Workbooks;
            xlBooks = (Excel.Workbooks)xlApplication.Workbooks;
            Excel._Workbook ThisWorkbook = (Excel._Workbook)(xlBooks.Add(Missing.Value));
            Excel.Worksheet xlSheet = (Excel.Worksheet)ThisWorkbook.Worksheets.Add(Type.Missing, ThisWorkbook.ActiveSheet, Type.Missing, Type.Missing);

            string[] strColumnFormat = new string[gdvGrid.Columns.Count + 1];
            for (int i = 0; i < dv.Count; i++)
            {
                int x = 0;
                for (int j = 0; j < gdvGrid.Columns.Count; j++)
                {
                    if (gdvGrid.Columns[j].Visible)
                    {
                        x++;
                        if (i == 0)
                        {
                            xlSheet.Cells[1, x] = gdvGrid.Columns[j].HeaderText;
                        }

                        //2009-01-19    Z    format column
                        if (strColumnFormat[x] == null || strColumnFormat[x].Length == 0)
                        {
                            if (dv.Table.Columns[j].DataType == typeof(string))
                            {
                                strColumnFormat[x] = "@";

                                try
                                {
                                    if (!(strColumnFormat[x] == null || strColumnFormat[x].Length == 0))
                                    {
                                        Excel.Range cell = null;

                                        cell = ((Excel.Range)xlSheet.Columns[string.Format("{0}:{0}", WP.Commons.ToExcel.GetColumnName(x)), System.Reflection.Missing.Value]);
                                        cell.NumberFormat = strColumnFormat[x];
                                        if (strColumnFormat[x].Equals("@"))
                                        {
                                            cell.HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlLeft;
                                        }

                                    }

                                }
                                catch (Exception ex)
                                {
                                    ExceptionManager.ProcessException(ex);
                                }
                            }
                            else if (dv.Table.Columns[j].DataType == typeof(decimal))
                            {
                                strColumnFormat[x] = "#,##0.00";

                                try
                                {
                                    if (!(strColumnFormat[x] == null || strColumnFormat[x].Length == 0))
                                    {
                                        Excel.Range cell = null;

                                        cell = ((Excel.Range)xlSheet.Columns[string.Format("{0}:{0}", WP.Commons.ToExcel.GetColumnName(x)), System.Reflection.Missing.Value]);
                                        cell.NumberFormat = strColumnFormat[x];

                                        cell.HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlRight;

                                    }

                                }
                                catch (Exception ex)
                                {
                                    ExceptionManager.ProcessException(ex);
                                }
                            }
                        }
                        xlSheet.Cells[i + 2, x] = dv[i][j];
                    }
                }
            }

            xlSheet.Columns.AutoFit();
            xlApplication.Visible = true;
        }

        public static void DataGirdViewToExcel(DataGridView gdvGrid)
        {
            if ( gdvGrid == null || gdvGrid.Columns.Count == 0) return;

            TableRange cell = null;

            TableSheet page = TableSheet.CreateAvailable(null);

            TableRange data = page.Range(page.CurrentRow, 1, page.CurrentRow + gdvGrid.Rows.Count, gdvGrid.Columns.Count);
            data.CreateArray();
            string[] strColumnFormat = new string[gdvGrid.Columns.Count + 1];
            for (int i = 0; i < gdvGrid.Rows.Count; i++)
            {
                int x = 0;
                for (int j = 0; j < gdvGrid.Columns.Count-1; j++)
                {
                    if (gdvGrid.Columns[j].Visible)
                    {
                        x++;
                        if (i == 0)
                        {
                            data[i, x - 1] = gdvGrid.Columns[j].HeaderText;
                        }

                        //2009-01-19    Z    format column
                        //if (strColumnFormat[x - 1] == null || strColumnFormat[x - 1].Length == 0)
                        //{
                        //    if (dv.Table.Columns[j].DataType == typeof(string))
                        //    {
                        //        strColumnFormat[x - 1] = "@";

                        //        try
                        //        {
                        //            if (!(strColumnFormat[x - 1] == null || strColumnFormat[x - 1].Length == 0))
                        //            {


                        //                cell = page.Columns(x);
                        //                cell.NumberFormat = strColumnFormat[x - 1];
                        //                if (strColumnFormat[x - 1].Equals("@"))
                        //                {
                        //                    cell.HAlign = HAlign.Left;
                        //                }

                        //            }

                        //        }
                        //        catch (Exception ex)
                        //        {
                        //            ExceptionManager.ProcessException(ex);
                        //        }
                        //    }
                        //    else if (dv.Table.Columns[j].DataType == typeof(decimal))
                        //    {
                        //        strColumnFormat[x - 1] = "#,##0";

                        //        try
                        //        {
                        //            if (!(strColumnFormat[x - 1] == null || strColumnFormat[x - 1].Length == 0))
                        //            {
                        //                cell = page.Columns(x);
                        //                cell.NumberFormat = strColumnFormat[x - 1];

                        //                cell.HAlign = HAlign.Right;
                        //            }

                        //        }
                        //        catch (Exception ex)
                        //        {
                        //            ExceptionManager.ProcessException(ex);
                        //        }
                        //    }
                        //}
                        data[i + 1, x - 1] = (gdvGrid.Rows[i].Cells[j].Value  == DBNull.Value ? string.Empty : gdvGrid.Rows[i].Cells[j].Value );
                    }
                }
            }

            data.FlushArray();

            page.AutoFitColumns();
            page.Visible = true;
        }

    }

    #endregion


}






